This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch 1.6.x_backports in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
commit 77b32c54196951d0f87264a55492d8ae32aa70fc Author: Michael Osipov <micha...@apache.org> AuthorDate: Mon Apr 26 09:08:23 2021 +0200 [MRESOLVER-171] Resolver fails when compiled on Java 9+ and run on Java 8 due to JDK API breakage --- .../aether/connector/basic/ChecksumCalculator.java | 11 ++++++----- .../aether/internal/impl/DefaultFileProcessor.java | 9 +++++---- .../spi/connector/transport/AbstractTransporter.java | 17 +++++++++-------- .../aether/internal/test/util/TestFileProcessor.java | 7 ++++--- .../transport/classpath/RecordingTransportListener.java | 7 ++++--- .../transport/file/RecordingTransportListener.java | 7 ++++--- .../transport/http/RecordingTransportListener.java | 7 ++++--- .../transport/wagon/RecordingTransportListener.java | 7 ++++--- 8 files changed, 40 insertions(+), 32 deletions(-) diff --git a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/ChecksumCalculator.java b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/ChecksumCalculator.java index e5a1780..14f4951 100644 --- a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/ChecksumCalculator.java +++ b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/ChecksumCalculator.java @@ -8,9 +8,9 @@ package org.eclipse.aether.connector.basic; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,6 +23,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -165,7 +166,7 @@ final class ChecksumCalculator read -= total - dataOffset; } buffer.rewind(); - buffer.limit( read ); + ( (Buffer) buffer ).limit( read ); update( buffer ); } @@ -199,9 +200,9 @@ final class ChecksumCalculator { for ( Checksum checksum : checksums ) { - data.mark(); + ( (Buffer) data ).mark(); checksum.update( data ); - data.reset(); + ( (Buffer) data ).reset(); } } diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultFileProcessor.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultFileProcessor.java index 6ba2915..e13d088 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultFileProcessor.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultFileProcessor.java @@ -8,9 +8,9 @@ package org.eclipse.aether.internal.impl; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -25,6 +25,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; @@ -44,7 +45,7 @@ public class DefaultFileProcessor * Thread-safe variant of {@link File#mkdirs()}. Creates the directory named by the given abstract pathname, * including any necessary but nonexistent parent directories. Note that if this operation fails it may have * succeeded in creating some of the necessary parent directories. - * + * * @param directory The directory to create, may be {@code null}. * @return {@code true} if and only if the directory was created, along with all necessary parent directories; * {@code false} otherwise @@ -230,7 +231,7 @@ public class DefaultFileProcessor try { buffer.rewind(); - buffer.limit( bytes ); + ( (Buffer) buffer ).limit( bytes ); listener.progressed( buffer ); } catch ( Exception e ) diff --git a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/AbstractTransporter.java b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/AbstractTransporter.java index 21a0da3..f420d0d 100644 --- a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/AbstractTransporter.java +++ b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/AbstractTransporter.java @@ -8,9 +8,9 @@ package org.eclipse.aether.spi.connector.transport; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,6 +22,7 @@ package org.eclipse.aether.spi.connector.transport; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.util.concurrent.atomic.AtomicBoolean; @@ -53,7 +54,7 @@ public abstract class AbstractTransporter /** * Implements {@link #peek(PeekTask)}, gets only called if the transporter has not been closed. - * + * * @param task The existence check to perform, must not be {@code null}. * @throws Exception If the existence of the specified resource could not be confirmed. */ @@ -69,7 +70,7 @@ public abstract class AbstractTransporter /** * Implements {@link #get(GetTask)}, gets only called if the transporter has not been closed. - * + * * @param task The download to perform, must not be {@code null}. * @throws Exception If the transfer failed. */ @@ -80,7 +81,7 @@ public abstract class AbstractTransporter * Performs stream-based I/O for the specified download task and notifies the configured transport listener. * Subclasses might want to invoke this utility method from within their {@link #implGet(GetTask)} to avoid * boilerplate I/O code. - * + * * @param task The download to perform, must not be {@code null}. * @param is The input stream to download the data from, must not be {@code null}. * @param close {@code true} if the supplied input stream should be automatically closed, {@code false} to leave the @@ -149,7 +150,7 @@ public abstract class AbstractTransporter /** * Implements {@link #put(PutTask)}, gets only called if the transporter has not been closed. - * + * * @param task The upload to perform, must not be {@code null}. * @throws Exception If the transfer failed. */ @@ -160,7 +161,7 @@ public abstract class AbstractTransporter * Performs stream-based I/O for the specified upload task and notifies the configured transport listener. * Subclasses might want to invoke this utility method from within their {@link #implPut(PutTask)} to avoid * boilerplate I/O code. - * + * * @param task The upload to perform, must not be {@code null}. * @param os The output stream to upload the data to, must not be {@code null}. * @param close {@code true} if the supplied output stream should be automatically closed, {@code false} to leave @@ -252,7 +253,7 @@ public abstract class AbstractTransporter { os.write( array, 0, read ); buffer.rewind(); - buffer.limit( read ); + ( (Buffer) buffer ).limit( read ); listener.transportProgressed( buffer ); } } diff --git a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestFileProcessor.java b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestFileProcessor.java index 118ef13..6fc36da 100644 --- a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestFileProcessor.java +++ b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestFileProcessor.java @@ -8,9 +8,9 @@ package org.eclipse.aether.internal.test.util; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -26,6 +26,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; @@ -219,7 +220,7 @@ public class TestFileProcessor try { buffer.rewind(); - buffer.limit( bytes ); + ( (Buffer) buffer ).limit( bytes ); listener.progressed( buffer ); } catch ( Exception e ) diff --git a/maven-resolver-transport-classpath/src/test/java/org/eclipse/aether/transport/classpath/RecordingTransportListener.java b/maven-resolver-transport-classpath/src/test/java/org/eclipse/aether/transport/classpath/RecordingTransportListener.java index 9447d39..8d453b1 100644 --- a/maven-resolver-transport-classpath/src/test/java/org/eclipse/aether/transport/classpath/RecordingTransportListener.java +++ b/maven-resolver-transport-classpath/src/test/java/org/eclipse/aether/transport/classpath/RecordingTransportListener.java @@ -8,9 +8,9 @@ package org.eclipse.aether.transport.classpath; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -20,6 +20,7 @@ package org.eclipse.aether.transport.classpath; */ import java.io.ByteArrayOutputStream; +import java.nio.Buffer; import java.nio.ByteBuffer; import org.eclipse.aether.spi.connector.transport.TransportListener; @@ -63,7 +64,7 @@ class RecordingTransportListener throws TransferCancelledException { progressedCount++; - baos.write( data.array(), data.arrayOffset() + data.position(), data.remaining() ); + baos.write( data.array(), data.arrayOffset() + ( (Buffer) data ).position(), data.remaining() ); if ( cancelProgress ) { throw new TransferCancelledException(); diff --git a/maven-resolver-transport-file/src/test/java/org/eclipse/aether/transport/file/RecordingTransportListener.java b/maven-resolver-transport-file/src/test/java/org/eclipse/aether/transport/file/RecordingTransportListener.java index c6331e0..76e3585 100644 --- a/maven-resolver-transport-file/src/test/java/org/eclipse/aether/transport/file/RecordingTransportListener.java +++ b/maven-resolver-transport-file/src/test/java/org/eclipse/aether/transport/file/RecordingTransportListener.java @@ -8,9 +8,9 @@ package org.eclipse.aether.transport.file; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -20,6 +20,7 @@ package org.eclipse.aether.transport.file; */ import java.io.ByteArrayOutputStream; +import java.nio.Buffer; import java.nio.ByteBuffer; import org.eclipse.aether.spi.connector.transport.TransportListener; @@ -63,7 +64,7 @@ class RecordingTransportListener throws TransferCancelledException { progressedCount++; - baos.write( data.array(), data.arrayOffset() + data.position(), data.remaining() ); + baos.write( data.array(), data.arrayOffset() + ( (Buffer) data ).position(), data.remaining() ); if ( cancelProgress ) { throw new TransferCancelledException(); diff --git a/maven-resolver-transport-http/src/test/java/org/eclipse/aether/transport/http/RecordingTransportListener.java b/maven-resolver-transport-http/src/test/java/org/eclipse/aether/transport/http/RecordingTransportListener.java index d88a320..e7ca7c9 100644 --- a/maven-resolver-transport-http/src/test/java/org/eclipse/aether/transport/http/RecordingTransportListener.java +++ b/maven-resolver-transport-http/src/test/java/org/eclipse/aether/transport/http/RecordingTransportListener.java @@ -8,9 +8,9 @@ package org.eclipse.aether.transport.http; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -20,6 +20,7 @@ package org.eclipse.aether.transport.http; */ import java.io.ByteArrayOutputStream; +import java.nio.Buffer; import java.nio.ByteBuffer; import org.eclipse.aether.spi.connector.transport.TransportListener; @@ -63,7 +64,7 @@ class RecordingTransportListener throws TransferCancelledException { progressedCount++; - baos.write( data.array(), data.arrayOffset() + data.position(), data.remaining() ); + baos.write( data.array(), data.arrayOffset() + ( (Buffer) data ).position(), data.remaining() ); if ( cancelProgress ) { throw new TransferCancelledException(); diff --git a/maven-resolver-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/RecordingTransportListener.java b/maven-resolver-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/RecordingTransportListener.java index 7f61985..3f1859d 100644 --- a/maven-resolver-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/RecordingTransportListener.java +++ b/maven-resolver-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/RecordingTransportListener.java @@ -8,9 +8,9 @@ package org.eclipse.aether.transport.wagon; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -20,6 +20,7 @@ package org.eclipse.aether.transport.wagon; */ import java.io.ByteArrayOutputStream; +import java.nio.Buffer; import java.nio.ByteBuffer; import org.eclipse.aether.spi.connector.transport.TransportListener; @@ -63,7 +64,7 @@ class RecordingTransportListener throws TransferCancelledException { progressedCount++; - baos.write( data.array(), data.arrayOffset() + data.position(), data.remaining() ); + baos.write( data.array(), data.arrayOffset() + ( (Buffer) data ).position(), data.remaining() ); if ( cancelProgress ) { throw new TransferCancelledException();