diff options
author | gjoranv <gv@oath.com> | 2018-04-25 16:14:39 +0200 |
---|---|---|
committer | gjoranv <gv@oath.com> | 2018-04-25 17:13:42 +0200 |
commit | 8f91dcc844a8669aeaae3fadebd564c08bc2ae08 (patch) | |
tree | 1d43a0d17d2731ecefbe8254d7527b6dae874482 /vespajlib | |
parent | 5bb60e592daa968125d492a2f1b0a3233e6bc8b2 (diff) |
Add extra downcast to avoid "redundant cast" warning on Java 9.
Diffstat (limited to 'vespajlib')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/io/ReadLine.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/io/ReadLine.java b/vespajlib/src/main/java/com/yahoo/io/ReadLine.java index 48c86cf0017..6e7f9f5e50e 100644 --- a/vespajlib/src/main/java/com/yahoo/io/ReadLine.java +++ b/vespajlib/src/main/java/com/yahoo/io/ReadLine.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.io; +import java.nio.Buffer; import java.nio.charset.Charset; import java.nio.ByteBuffer; @@ -44,9 +45,11 @@ public class ReadLine { continue; } - // extract string between start and i. limit() returns - // a buffer so we have to up-cast again - String line = charset.decode((ByteBuffer) buffer.slice().limit(i - start)).toString(); + // limit() returns a buffer (before Java 9) so we have to up-cast. + // The downcast to Buffer is done to avoid "redundant cast" warning on Java 9. + // TODO: when Java 8 is gone, remove the casts and above comments. + // extract string between start and i. + String line = charset.decode((ByteBuffer) ((Buffer)buffer.slice()).limit(i - start)).toString(); // skip remaining for (; (i < buffer.limit()) && isEolChar(buffer.get(i)); i++) { |