Skip to content

Commit

Permalink
[#2308] improvement(server): More detailed and clear logs on reading …
Browse files Browse the repository at this point in the history
…failure for FileSegmentManagedBuffer (#2309)

### What changes were proposed in this pull request?

More detailed and clear logs on reading failure for FileSegmentManagedBuffer

### Why are the changes needed?

for #2308 

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Needn't

Co-authored-by: Junfan Zhang <[email protected]>
  • Loading branch information
zuston and Junfan Zhang authored Jan 2, 2025
1 parent 9396abc commit c90d463
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ public ByteBuffer nioByteBuffer() {
buf.flip();
return buf;
} catch (IOException e) {
String errorMessage = "Error in reading " + this;
String fileName = file.getAbsolutePath();
String errorMessage =
String.format(
"Errors on reading localfile data with offset[%s] length[%s] from [%s]. ",
offset, length, fileName);
try {
if (channel != null) {
long size = channel.size();
errorMessage = "Error in reading " + this + " (actual file length " + size + ")";
errorMessage += String.format("The actual file length: %s", size);
}
} catch (IOException ignored) {
// ignore
Expand Down Expand Up @@ -107,7 +111,7 @@ public Object convertToNetty() {
try {
fileChannel = FileChannel.open(file.toPath(), StandardOpenOption.READ);
} catch (IOException e) {
throw new RssException("Error in reading " + file);
throw new RssException("Errors on reading " + file.getAbsolutePath(), e);
}
return new DefaultFileRegion(fileChannel, offset, length);
}
Expand Down

0 comments on commit c90d463

Please sign in to comment.