Skip to content

Commit

Permalink
8266320: (bf) ReadOnlyBufferException in heap buffer put(String,int,i…
Browse files Browse the repository at this point in the history
…nt) should not be conditional

Reviewed-by: alanb, bpb
  • Loading branch information
marschall authored and Brian Burkhalter committed May 3, 2021
1 parent ff65920 commit 45760d4
Showing 1 changed file with 5 additions and 3 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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
Expand Down Expand Up @@ -272,11 +272,10 @@ class Heap$Type$Buffer$RW$
#if[char]

public $Type$Buffer put(String src, int start, int end) {
#if[rw]
checkScope();
int length = end - start;
Objects.checkFromIndexSize(start, length, src.length());
if (isReadOnly())
throw new ReadOnlyBufferException();
int pos = position();
int lim = limit();
int rem = (pos <= lim) ? lim - pos : 0;
Expand All @@ -285,6 +284,9 @@ class Heap$Type$Buffer$RW$
src.getChars(start, end, hb, ix(pos));
position(pos + length);
return this;
#else[rw]
throw new ReadOnlyBufferException();
#end[rw]
}

#end[char]
Expand Down

1 comment on commit 45760d4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.