This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch MRESOLVER-152 in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
commit 9295e3b60c7f970e129c8f76714424447e0882fb Author: Michael Osipov <micha...@apache.org> AuthorDate: Wed Dec 23 11:08:46 2020 +0100 First shot --- .../basic/BasicRepositoryConnectorFactory.java | 9 ++++++--- .../internal/impl/DefaultTransporterProvider.java | 3 ++- .../impl/EnhancedLocalRepositoryManagerFactory.java | 11 ++++++++--- .../impl/SimpleLocalRepositoryManagerFactory.java | 11 ++++++++--- .../connector/transport/AbstractTransporter.java | 21 ++++++++++++++------- .../classpath/ClasspathTransporterFactory.java | 11 ++++++++--- .../transport/file/FileTransporterFactory.java | 11 ++++++++--- .../transport/http/HttpTransporterFactory.java | 11 ++++++++--- .../transport/wagon/PlexusWagonConfigurator.java | 11 +++++------ .../aether/transport/wagon/WagonTransporter.java | 7 +++++-- .../transport/wagon/WagonTransporterFactory.java | 15 ++++++++++----- 11 files changed, 82 insertions(+), 39 deletions(-) diff --git a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java index 540b301..aa747a9 100644 --- a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java +++ b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.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 @@ -139,7 +139,7 @@ public final class BasicRepositoryConnectorFactory /** * Sets the priority of this component. - * + * * @param priority The priority. * @return This component for chaining, never {@code null}. */ @@ -152,6 +152,9 @@ public final class BasicRepositoryConnectorFactory public RepositoryConnector newInstance( RepositorySystemSession session, RemoteRepository repository ) throws NoRepositoryConnectorException { + requireNonNull( "session", "session cannot be null" ); + requireNonNull( "repository", "repository cannot be null" ); + return new BasicRepositoryConnector( session, repository, transporterProvider, layoutProvider, checksumPolicyProvider, fileProcessor ); } diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java index 550191d..fed7c1b 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java @@ -88,7 +88,8 @@ public final class DefaultTransporterProvider public Transporter newTransporter( RepositorySystemSession session, RemoteRepository repository ) throws NoTransporterException { - requireNonNull( repository, "remote repository cannot be null" ); + requireNonNull( "session", "session cannot be null" ); + requireNonNull( "repository", "repository cannot be null" ); PrioritizedComponents<TransporterFactory> factories = new PrioritizedComponents<>( session ); for ( TransporterFactory factory : this.factories ) diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java index fdf6b38..5058cab 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.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 @@ -21,6 +21,8 @@ package org.eclipse.aether.internal.impl; import javax.inject.Named; +import java.util.Objects; + import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.LocalRepositoryManager; @@ -48,6 +50,9 @@ public class EnhancedLocalRepositoryManagerFactory public LocalRepositoryManager newInstance( RepositorySystemSession session, LocalRepository repository ) throws NoLocalRepositoryManagerException { + Objects.requireNonNull( "session", "session cannot be null" ); + Objects.requireNonNull( "repository", "repository cannot be null" ); + if ( "".equals( repository.getContentType() ) || "default".equals( repository.getContentType() ) ) { return new EnhancedLocalRepositoryManager( repository.getBasedir(), session ); @@ -65,7 +70,7 @@ public class EnhancedLocalRepositoryManagerFactory /** * Sets the priority of this component. - * + * * @param priority The priority. * @return This component for chaining, never {@code null}. */ diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java index c0426e8..23f9f89 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.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 @@ -21,6 +21,8 @@ package org.eclipse.aether.internal.impl; import javax.inject.Named; +import java.util.Objects; + import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.LocalRepositoryManager; @@ -44,6 +46,9 @@ public class SimpleLocalRepositoryManagerFactory public LocalRepositoryManager newInstance( RepositorySystemSession session, LocalRepository repository ) throws NoLocalRepositoryManagerException { + Objects.requireNonNull( "session", "session cannot be null" ); + Objects.requireNonNull( "repository", "repository cannot be null" ); + if ( "".equals( repository.getContentType() ) || "simple".equals( repository.getContentType() ) ) { return new SimpleLocalRepositoryManager( repository.getBasedir() ); @@ -61,7 +66,7 @@ public class SimpleLocalRepositoryManagerFactory /** * Sets the priority of this component. - * + * * @param priority The priority. * @return This component for chaining, never {@code null}. */ 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..63d9817 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 @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; +import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.aether.transfer.TransferCancelledException; @@ -47,13 +48,15 @@ public abstract class AbstractTransporter public void peek( PeekTask task ) throws Exception { + Objects.requireNonNull( "task", "task cannot be null" ); + failIfClosed( task ); implPeek( task ); } /** * 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. */ @@ -63,13 +66,15 @@ public abstract class AbstractTransporter public void get( GetTask task ) throws Exception { + Objects.requireNonNull( "task", "task cannot be null" ); + failIfClosed( task ); implGet( task ); } /** * 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 +85,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 @@ -143,13 +148,15 @@ public abstract class AbstractTransporter public void put( PutTask task ) throws Exception { + Objects.requireNonNull( "task", "task cannot be null" ); + failIfClosed( task ); implPut( task ); } /** * 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 +167,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 diff --git a/maven-resolver-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporterFactory.java b/maven-resolver-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporterFactory.java index a1004be..5f5b48d 100644 --- a/maven-resolver-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporterFactory.java +++ b/maven-resolver-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporterFactory.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 @@ -21,6 +21,8 @@ package org.eclipse.aether.transport.classpath; import javax.inject.Named; +import java.util.Objects; + import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.spi.connector.transport.Transporter; @@ -67,7 +69,7 @@ public final class ClasspathTransporterFactory /** * Sets the priority of this component. - * + * * @param priority The priority. * @return This component for chaining, never {@code null}. */ @@ -80,6 +82,9 @@ public final class ClasspathTransporterFactory public Transporter newInstance( RepositorySystemSession session, RemoteRepository repository ) throws NoTransporterException { + Objects.requireNonNull( "session", "session cannot be null" ); + Objects.requireNonNull( "repository", "repository cannot be null" ); + return new ClasspathTransporter( session, repository ); } diff --git a/maven-resolver-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporterFactory.java b/maven-resolver-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporterFactory.java index bf78a6b..42e651f 100644 --- a/maven-resolver-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporterFactory.java +++ b/maven-resolver-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporterFactory.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 @@ -21,6 +21,8 @@ package org.eclipse.aether.transport.file; import javax.inject.Named; +import java.util.Objects; + import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.spi.connector.transport.Transporter; @@ -54,7 +56,7 @@ public final class FileTransporterFactory /** * Sets the priority of this component. - * + * * @param priority The priority. * @return This component for chaining, never {@code null}. */ @@ -67,6 +69,9 @@ public final class FileTransporterFactory public Transporter newInstance( RepositorySystemSession session, RemoteRepository repository ) throws NoTransporterException { + Objects.requireNonNull( "session", "session cannot be null" ); + Objects.requireNonNull( "repository", "repository cannot be null" ); + return new FileTransporter( repository ); } diff --git a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporterFactory.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporterFactory.java index 5e329ca..1747891 100644 --- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporterFactory.java +++ b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporterFactory.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 @@ -21,6 +21,8 @@ package org.eclipse.aether.transport.http; import javax.inject.Named; +import java.util.Objects; + import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.spi.connector.transport.Transporter; @@ -55,7 +57,7 @@ public final class HttpTransporterFactory /** * Sets the priority of this component. - * + * * @param priority The priority. * @return This component for chaining, never {@code null}. */ @@ -68,6 +70,9 @@ public final class HttpTransporterFactory public Transporter newInstance( RepositorySystemSession session, RemoteRepository repository ) throws NoTransporterException { + Objects.requireNonNull( "session", "session cannot be null" ); + Objects.requireNonNull( "repository", "repository cannot be null" ); + return new HttpTransporter( repository, session ); } diff --git a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonConfigurator.java b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonConfigurator.java index a6d150c..7f8d7dc 100644 --- a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonConfigurator.java +++ b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonConfigurator.java @@ -8,9 +8,9 @@ package org.eclipse.aether.internal.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 @@ -62,6 +62,9 @@ public class PlexusWagonConfigurator public void configure( Wagon wagon, Object configuration ) throws Exception { + requireNonNull( wagon, "wagon cannot be null" ); + requireNonNull( configuration, "configuration cannot be null" ); + PlexusConfiguration config; if ( configuration instanceof PlexusConfiguration ) { @@ -71,10 +74,6 @@ public class PlexusWagonConfigurator { config = new XmlPlexusConfiguration( (Xpp3Dom) configuration ); } - else if ( configuration == null ) - { - return; - } else { throw new IllegalArgumentException( "unexpected configuration type: " diff --git a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporter.java b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporter.java index c1eb637..6441d0c 100644 --- a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporter.java +++ b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporter.java @@ -29,6 +29,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Properties; import java.util.Queue; import java.util.UUID; @@ -415,6 +416,8 @@ final class WagonTransporter private void execute( TransportTask task, TaskRunner runner ) throws Exception { + Objects.requireNonNull( "task", "task cannot be null" ); + if ( closed.get() ) { throw new IllegalStateException( "transporter closed, cannot execute task " + task ); @@ -625,9 +628,9 @@ final class WagonTransporter throws IOException { File tmp = newTempFile(); - + try ( InputStream in = task.newInputStream(); - OutputStream out = new FileOutputStream( tmp ) ) + OutputStream out = new FileOutputStream( tmp ) ) { copy( out, in ); } diff --git a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporterFactory.java b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporterFactory.java index 75329e6..a8487d6 100644 --- a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporterFactory.java +++ b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/transport/wagon/WagonTransporterFactory.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 @@ -22,6 +22,8 @@ package org.eclipse.aether.transport.wagon; import javax.inject.Inject; import javax.inject.Named; +import java.util.Objects; + import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.spi.connector.transport.Transporter; @@ -71,7 +73,7 @@ public final class WagonTransporterFactory /** * Sets the wagon provider to use to acquire and release wagon instances. - * + * * @param wagonProvider The wagon provider to use, may be {@code null}. * @return This factory for chaining, never {@code null}. */ @@ -83,7 +85,7 @@ public final class WagonTransporterFactory /** * Sets the wagon configurator to use to apply provider-specific configuration to wagon instances. - * + * * @param wagonConfigurator The wagon configurator to use, may be {@code null}. * @return This factory for chaining, never {@code null}. */ @@ -100,7 +102,7 @@ public final class WagonTransporterFactory /** * Sets the priority of this component. - * + * * @param priority The priority. * @return This component for chaining, never {@code null}. */ @@ -113,6 +115,9 @@ public final class WagonTransporterFactory public Transporter newInstance( RepositorySystemSession session, RemoteRepository repository ) throws NoTransporterException { + Objects.requireNonNull( "session", "session cannot be null" ); + Objects.requireNonNull( "repository", "repository cannot be null" ); + return new WagonTransporter( wagonProvider, wagonConfigurator, repository, session ); }