Repository: maven Updated Branches: refs/heads/master 6c4627bd4 -> 0535716fd
[MNG-5967] Dependency updates. o Updated to 'plexus-utils-3.0.23'. o Updated to stop suppressing exceptions incorrectly when closing resources. Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/0535716f Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/0535716f Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/0535716f Branch: refs/heads/master Commit: 0535716fd602eb056ed791b89d7f9a3fb882499c Parents: 6c4627b Author: Christian Schulte <schu...@apache.org> Authored: Wed May 4 21:01:24 2016 +0200 Committer: Christian Schulte <schu...@apache.org> Committed: Thu May 5 00:35:01 2016 +0200 ---------------------------------------------------------------------- .../internal/DefaultVersionRangeResolver.java | 19 ++++++++-- .../internal/DefaultVersionResolver.java | 18 ++++++++-- .../metadata/io/DefaultMetadataReader.java | 16 ++++++--- .../toolchain/io/DefaultToolchainsReader.java | 18 +++++++--- .../maven/model/io/DefaultModelReader.java | 38 ++++++++------------ .../maven/model/io/DefaultModelWriter.java | 24 ++++++------- .../settings/io/DefaultSettingsReader.java | 16 ++++++--- .../settings/io/DefaultSettingsWriter.java | 24 ++++++------- pom.xml | 2 +- 9 files changed, 106 insertions(+), 69 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven/blob/0535716f/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java ---------------------------------------------------------------------- diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java index ddd3e97..7df7847 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java @@ -24,7 +24,6 @@ import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.util.IOUtil; import org.eclipse.aether.RepositoryEvent; import org.eclipse.aether.RepositoryEvent.EventType; import org.eclipse.aether.RepositorySystemSession; @@ -58,6 +57,7 @@ import org.eclipse.aether.version.VersionScheme; import javax.inject.Inject; import javax.inject.Named; import java.io.FileInputStream; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -272,8 +272,13 @@ public class DefaultVersionRangeResolver if ( metadata.getFile() != null && metadata.getFile().exists() ) { fis = new FileInputStream( metadata.getFile() ); + org.apache.maven.artifact.repository.metadata.Metadata m = new MetadataXpp3Reader().read( fis, false ); + + fis.close(); + fis = null; + versioning = m.getVersioning(); } } @@ -286,7 +291,17 @@ public class DefaultVersionRangeResolver } finally { - IOUtil.close( fis ); + try + { + if ( fis != null ) + { + fis.close(); + } + } + catch ( final IOException e ) + { + this.logger.warn( "Failure closing file.", e ); + } } return ( versioning != null ) ? versioning : new Versioning(); http://git-wip-us.apache.org/repos/asf/maven/blob/0535716f/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java ---------------------------------------------------------------------- diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java index 2b0890b..eb2efd7 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java @@ -26,7 +26,6 @@ import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; import org.eclipse.aether.RepositoryCache; import org.eclipse.aether.RepositoryEvent; @@ -338,8 +337,13 @@ public class DefaultVersionResolver if ( metadata.getFile() != null && metadata.getFile().exists() ) { fis = new FileInputStream( metadata.getFile() ); + org.apache.maven.artifact.repository.metadata.Metadata m = new MetadataXpp3Reader().read( fis, false ); + + fis.close(); + fis = null; + versioning = m.getVersioning(); /* @@ -374,7 +378,17 @@ public class DefaultVersionResolver } finally { - IOUtil.close( fis ); + try + { + if ( fis != null ) + { + fis.close(); + } + } + catch ( final IOException e ) + { + this.logger.warn( "Failure closing file.", e ); + } } return ( versioning != null ) ? versioning : new Versioning(); http://git-wip-us.apache.org/repos/asf/maven/blob/0535716f/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java index c769f89..f611588 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java @@ -60,8 +60,12 @@ public class DefaultMetadataReader try { - MetadataXpp3Reader r = new MetadataXpp3Reader(); - return r.read( input, isStrict( options ) ); + final Metadata metadata = new MetadataXpp3Reader().read( input, isStrict( options ) ); + + input.close(); + input = null; + + return metadata; } catch ( XmlPullParserException e ) { @@ -80,8 +84,12 @@ public class DefaultMetadataReader try { - MetadataXpp3Reader r = new MetadataXpp3Reader(); - return r.read( input, isStrict( options ) ); + final Metadata metadata = new MetadataXpp3Reader().read( input, isStrict( options ) ); + + input.close(); + input = null; + + return metadata; } catch ( XmlPullParserException e ) { http://git-wip-us.apache.org/repos/asf/maven/blob/0535716f/maven-core/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java b/maven-core/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java index 9b5bdd7..29f16cc 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java @@ -64,8 +64,13 @@ public class DefaultToolchainsReader try { - MavenToolchainsXpp3Reader r = new MavenToolchainsXpp3Reader(); - return r.read( input, isStrict( options ) ); + final PersistedToolchains persistedToolchains = + new MavenToolchainsXpp3Reader().read( input, isStrict( options ) ); + + input.close(); + input = null; + + return persistedToolchains; } catch ( XmlPullParserException e ) { @@ -85,8 +90,13 @@ public class DefaultToolchainsReader try { - MavenToolchainsXpp3Reader r = new MavenToolchainsXpp3Reader(); - return r.read( input, isStrict( options ) ); + final PersistedToolchains persistedToolchains = + new MavenToolchainsXpp3Reader().read( input, isStrict( options ) ); + + input.close(); + input = null; + + return persistedToolchains; } catch ( XmlPullParserException e ) { http://git-wip-us.apache.org/repos/asf/maven/blob/0535716f/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java b/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java index 0ba6673..86616ba 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java @@ -65,14 +65,7 @@ public class DefaultModelReader { Validate.notNull( input, "input cannot be null" ); - try - { - return read( input, isStrict( options ), getSource( options ) ); - } - finally - { - IOUtil.close( input ); - } + return read( input, isStrict( options ), getSource( options ) ); } @Override @@ -81,14 +74,7 @@ public class DefaultModelReader { Validate.notNull( input, "input cannot be null" ); - try - { - return read( ReaderFactory.newXmlReader( input ), isStrict( options ), getSource( options ) ); - } - finally - { - IOUtil.close( input ); - } + return read( ReaderFactory.newXmlReader( input ), isStrict( options ), getSource( options ) ); } private boolean isStrict( Map<String, ?> options ) @@ -108,19 +94,23 @@ public class DefaultModelReader { try { - if ( source != null ) - { - return new MavenXpp3ReaderEx().read( reader, strict, source ); - } - else - { - return new MavenXpp3Reader().read( reader, strict ); - } + final Model model = source != null + ? new MavenXpp3ReaderEx().read( reader, strict, source ) + : new MavenXpp3Reader().read( reader, strict ); + + reader.close(); + reader = null; + + return model; } catch ( XmlPullParserException e ) { throw new ModelParseException( e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e ); } + finally + { + IOUtil.close( reader ); + } } } http://git-wip-us.apache.org/repos/asf/maven/blob/0535716f/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java b/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java index 0d9af13..158de42 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java @@ -64,8 +64,10 @@ public class DefaultModelWriter try { - MavenXpp3Writer w = new MavenXpp3Writer(); - w.write( output, model ); + new MavenXpp3Writer().write( output, model ); + + output.close(); + output = null; } finally { @@ -80,20 +82,14 @@ public class DefaultModelWriter Validate.notNull( output, "output cannot be null" ); Validate.notNull( model, "model cannot be null" ); - try + String encoding = model.getModelEncoding(); + // TODO Use StringUtils here + if ( encoding == null || encoding.length() <= 0 ) { - String encoding = model.getModelEncoding(); - // TODO Use StringUtils here - if ( encoding == null || encoding.length() <= 0 ) - { - encoding = "UTF-8"; - } - write( new OutputStreamWriter( output, encoding ), options, model ); - } - finally - { - IOUtil.close( output ); + encoding = "UTF-8"; } + + write( new OutputStreamWriter( output, encoding ), options, model ); } } http://git-wip-us.apache.org/repos/asf/maven/blob/0535716f/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsReader.java ---------------------------------------------------------------------- diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsReader.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsReader.java index 9beee97..8e98c43 100644 --- a/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsReader.java +++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsReader.java @@ -62,8 +62,12 @@ public class DefaultSettingsReader try { - SettingsXpp3Reader r = new SettingsXpp3Reader(); - return r.read( input, isStrict( options ) ); + final Settings settings = new SettingsXpp3Reader().read( input, isStrict( options ) ); + + input.close(); + input = null; + + return settings; } catch ( XmlPullParserException e ) { @@ -83,8 +87,12 @@ public class DefaultSettingsReader try { - SettingsXpp3Reader r = new SettingsXpp3Reader(); - return r.read( input, isStrict( options ) ); + final Settings settings = new SettingsXpp3Reader().read( input, isStrict( options ) ); + + input.close(); + input = null; + + return settings; } catch ( XmlPullParserException e ) { http://git-wip-us.apache.org/repos/asf/maven/blob/0535716f/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsWriter.java ---------------------------------------------------------------------- diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsWriter.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsWriter.java index 877fbde..d9741a5 100644 --- a/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsWriter.java +++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsWriter.java @@ -64,8 +64,10 @@ public class DefaultSettingsWriter try { - SettingsXpp3Writer w = new SettingsXpp3Writer(); - w.write( output, settings ); + new SettingsXpp3Writer().write( output, settings ); + + output.close(); + output = null; } finally { @@ -80,20 +82,14 @@ public class DefaultSettingsWriter Validate.notNull( output, "output cannot be null" ); Validate.notNull( settings, "settings cannot be null" ); - try + String encoding = settings.getModelEncoding(); + // TODO Use StringUtils here + if ( encoding == null || encoding.length() <= 0 ) { - String encoding = settings.getModelEncoding(); - // TODO Use StringUtils here - if ( encoding == null || encoding.length() <= 0 ) - { - encoding = "UTF-8"; - } - write( new OutputStreamWriter( output, encoding ), options, settings ); - } - finally - { - IOUtil.close( output ); + encoding = "UTF-8"; } + + write( new OutputStreamWriter( output, encoding ), options, settings ); } } http://git-wip-us.apache.org/repos/asf/maven/blob/0535716f/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index cf30034..4ad6737 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ <junitVersion>4.12</junitVersion> <plexusVersion>1.6</plexusVersion> <plexusInterpolationVersion>1.22</plexusInterpolationVersion> - <plexusUtilsVersion>3.0.22</plexusUtilsVersion> + <plexusUtilsVersion>3.0.23</plexusUtilsVersion> <guavaVersion>19.0</guavaVersion> <guiceVersion>4.0</guiceVersion> <sisuInjectVersion>0.3.3</sisuInjectVersion>