mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-28 03:43:21 +00:00
8295456: (ch) sun.nio.ch.Util::checkBufferPositionAligned gives misleading/incorrect error
Reviewed-by: alanb
This commit is contained in:
parent
e27bea0c4d
commit
a5f6e31ccb
@ -502,19 +502,18 @@ public class Util {
|
||||
return dbb;
|
||||
}
|
||||
|
||||
static void checkBufferPositionAligned(ByteBuffer bb,
|
||||
int pos, int alignment)
|
||||
static void checkBufferPositionAligned(ByteBuffer bb, int pos, int alignment)
|
||||
throws IOException
|
||||
{
|
||||
if (bb.alignmentOffset(pos, alignment) != 0) {
|
||||
throw new IOException("Current location of the bytebuffer ("
|
||||
final int alignmentOffset = bb.alignmentOffset(pos, alignment);
|
||||
if (alignmentOffset != 0) {
|
||||
throw new IOException("Current position of the bytebuffer ("
|
||||
+ pos + ") is not a multiple of the block size ("
|
||||
+ alignment + ")");
|
||||
+ alignment + "): alignment offset = " + alignmentOffset);
|
||||
}
|
||||
}
|
||||
|
||||
static void checkRemainingBufferSizeAligned(int rem,
|
||||
int alignment)
|
||||
static void checkRemainingBufferSizeAligned(int rem, int alignment)
|
||||
throws IOException
|
||||
{
|
||||
if (rem % alignment != 0) {
|
||||
@ -524,8 +523,7 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
static void checkChannelPositionAligned(long position,
|
||||
int alignment)
|
||||
static void checkChannelPositionAligned(long position, int alignment)
|
||||
throws IOException
|
||||
{
|
||||
if (position % alignment != 0) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -144,7 +144,7 @@ public class ReadDirect {
|
||||
fc.read(block);
|
||||
throw new RuntimeException("Expected exception not thrown");
|
||||
} catch (IOException e) {
|
||||
if (!e.getMessage().contains("Current location of the bytebuffer "
|
||||
if (!e.getMessage().contains("Current position of the bytebuffer "
|
||||
+ "(" + pos + ") is not a multiple of the block size ("
|
||||
+ alignment + ")"))
|
||||
throw new Exception("Read test failed");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -101,7 +101,7 @@ public class WriteDirect {
|
||||
fc.write(block);
|
||||
throw new RuntimeException("Expected exception not thrown");
|
||||
} catch (IOException e) {
|
||||
if (!e.getMessage().contains("Current location of the bytebuffer "
|
||||
if (!e.getMessage().contains("Current position of the bytebuffer "
|
||||
+ "(" + pos + ") is not a multiple of the block size ("
|
||||
+ alignment + ")"))
|
||||
throw new Exception("Write test failed");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user