Skip to content

Commit 41193a8

Browse files
committed
fix BufferedIO when size may change while reading
reduce logging in ReadableToSeekable
1 parent 35aecb6 commit 41193a8

File tree

7 files changed

+19
-8
lines changed

7 files changed

+19
-8
lines changed

core.javaee/.settings/org.sonarlint.eclipse.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ fileExclusions=
55
idePrefixKey=
66
projectKey=lecousin_java-framework-core
77
serverId=SonarCloud/lecousin
8-
sqPrefixKey=
8+
sqPrefixKey=core.javaee

core.loaders/maven/.settings/org.sonarlint.eclipse.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ fileExclusions=
55
idePrefixKey=
66
projectKey=lecousin_java-framework-core
77
serverId=SonarCloud/lecousin
8-
sqPrefixKey=
8+
sqPrefixKey=core.loaders/maven

net.lecousin.core/.settings/org.sonarlint.eclipse.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ fileExclusions=
55
idePrefixKey=
66
projectKey=lecousin_java-framework-core
77
serverId=SonarCloud/lecousin
8-
sqPrefixKey=
8+
sqPrefixKey=net.lecousin.core

net.lecousin.core/src/main/java/net/lecousin/framework/io/buffering/BufferedIO.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,15 +1149,16 @@ private void readAsync(
11491149
if (!checkLoaded(b, result, ondone)) return;
11501150
int off = getBufferOffset(pos);
11511151
int len = buffer.remaining();
1152+
long s = size;
11521153
try {
11531154
if (len > b.data.length - off) len = b.data.length - off;
1154-
if (pos + len > size) len = (int)(size - pos);
1155+
if (pos + len > s) len = (int)(s - pos);
11551156
buffer.put(b.data, off, len);
11561157
b.lastRead = System.currentTimeMillis();
11571158
} catch (Exception t) {
11581159
result.error(new IOException("Error reading from BufferedIO buffer at " + pos + " offset " + off + " len="
1159-
+ len + " size=" + size + " buffer len=" + (b.data != null ? Integer.toString(b.data.length) : null)
1160-
+ " remaining=" + buffer.remaining(), t));
1160+
+ len + " size=" + size + " (" + s + ") buffer len="
1161+
+ (b.data != null ? Integer.toString(b.data.length) : null) + " remaining=" + buffer.remaining(), t));
11611162
} finally {
11621163
b.usage.endRead();
11631164
}

net.lecousin.core/src/main/java/net/lecousin/framework/io/buffering/ReadableToSeekable.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,11 @@ public AsyncSupplier<Long,IOException> seekAsync(SeekType type, long move, Consu
469469
public Long run() throws IOException {
470470
return Long.valueOf(seekSync(type, move));
471471
}
472+
473+
@Override
474+
public long getMaxBlockingTimeInNanoBeforeToLog() {
475+
return Long.MAX_VALUE;
476+
}
472477
};
473478
operation(task.start());
474479
return task.getOutput();
@@ -539,6 +544,11 @@ public AsyncSupplier<Long,IOException> skipAsync(long move, Consumer<Pair<Long,I
539544
public Long run() throws IOException {
540545
return Long.valueOf(skipSync(move));
541546
}
547+
548+
@Override
549+
public long getMaxBlockingTimeInNanoBeforeToLog() {
550+
return Long.MAX_VALUE;
551+
}
542552
};
543553
operation(task.start());
544554
return task.getOutput();

net.lecousin.framework.log.bridges/commons-logging/.settings/org.sonarlint.eclipse.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ fileExclusions=
55
idePrefixKey=
66
projectKey=lecousin_java-framework-core
77
serverId=SonarCloud/lecousin
8-
sqPrefixKey=
8+
sqPrefixKey=net.lecousin.framework.log.bridges/commons-logging

net.lecousin.framework.log.bridges/slf4j/.settings/org.sonarlint.eclipse.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ fileExclusions=
55
idePrefixKey=
66
projectKey=lecousin_java-framework-core
77
serverId=SonarCloud/lecousin
8-
sqPrefixKey=
8+
sqPrefixKey=net.lecousin.framework.log.bridges/slf4j

0 commit comments

Comments
 (0)