You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2022/01/19 17:12:04 UTC

[maven-surefire] branch master updated: [SUREFIRE-1982] Fix failures (java.nio.ChartBuffer) when compiled on Java 9+ and run on Java 8

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/master by this push:
     new 747c757  [SUREFIRE-1982] Fix failures (java.nio.ChartBuffer) when compiled on Java 9+ and run on Java 8
747c757 is described below

commit 747c757c0f6885554ff054ee0b1effbbe3325f46
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Wed Jan 19 18:09:56 2022 +0100

    [SUREFIRE-1982] Fix failures (java.nio.ChartBuffer) when compiled on Java 9+ and run on Java 8
---
 .../maven/surefire/api/stream/AbstractStreamDecoder.java       | 10 +++++-----
 .../maven/surefire/api/stream/AbstractStreamDecoderTest.java   |  8 ++++----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoder.java b/surefire-api/src/main/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoder.java
index bcfaee9..de197d5 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoder.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoder.java
@@ -171,7 +171,7 @@ public abstract class AbstractStreamDecoder<M, MT extends Enum<MT>, ST extends E
 
     protected String readString( @Nonnull Memento memento ) throws IOException, MalformedFrameException
     {
-        memento.getCharBuffer().clear();
+        ( (Buffer) memento.getCharBuffer() ).clear();
         int readCount = readInt( memento );
         if ( readCount < 0 )
         {
@@ -293,7 +293,7 @@ public abstract class AbstractStreamDecoder<M, MT extends Enum<MT>, ST extends E
     {
         memento.getDecoder().reset();
         final CharBuffer output = memento.getCharBuffer();
-        output.clear();
+        ( (Buffer) output ).clear();
         final ByteBuffer input = memento.getByteBuffer();
         final List<String> strings = new ArrayList<>();
         int countDecodedBytes = 0;
@@ -317,13 +317,13 @@ public abstract class AbstractStreamDecoder<M, MT extends Enum<MT>, ST extends E
 
             if ( isLastChunk || !output.hasRemaining() )
             {
-                strings.add( output.flip().toString() );
-                output.clear();
+                strings.add( ( (Buffer) output ).flip().toString() );
+                ( (Buffer) output ).clear();
             }
         }
 
         memento.getDecoder().reset();
-        output.clear();
+        ( (Buffer) output ).clear();
 
         return toString( strings );
     }
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoderTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoderTest.java
index 36ef828..8d4e1c5 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoderTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoderTest.java
@@ -151,7 +151,7 @@ public class AbstractStreamDecoderTest
         ByteBuffer input = ByteBuffer.allocate( 1024 );
         ( (Buffer) input.put( PATTERN2_BYTES ) ).flip();
         int bytesToDecode = PATTERN2_BYTES.length;
-        CharBuffer output = CharBuffer.allocate( 1024 );
+        Buffer output = CharBuffer.allocate( 1024 );
         int readBytes = invokeMethod( AbstractStreamDecoder.class, "decodeString", decoder, input, output,
             bytesToDecode, true, 0 );
 
@@ -172,7 +172,7 @@ public class AbstractStreamDecoderTest
             .put( 91, (byte) 'B' )
             .put( 92, (byte) 'C' ) )
             .position( 90 );
-        CharBuffer output = CharBuffer.allocate( 1024 );
+        Buffer output = CharBuffer.allocate( 1024 );
         int readBytes =
             invokeMethod( AbstractStreamDecoder.class, "decodeString", decoder, input, output, 2, true, 0 );
 
@@ -371,9 +371,9 @@ public class AbstractStreamDecoderTest
         {
             decoder.reset()
                 .decode( buffer, chars, true ); // CharsetDecoder 71 nanos
-            s = chars.flip().toString(); // CharsetDecoder + toString = 91 nanos
+            s = ( (Buffer) chars ).flip().toString(); // CharsetDecoder + toString = 91 nanos
             ( (Buffer) buffer ).clear();
-            chars.clear();
+            ( (Buffer) chars ).clear();
         }
         long l2 = System.currentTimeMillis();
         System.out.println( "decoded 100 bytes within " + ( l2 - l1 ) + " millis (10 million cycles)" );