Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

NEXUS-5383: More checks needed

After initial fix, another check is needed in operation.
Also, a smaller fix added, to not create VersionComparator
per list entry, but per operation instance.
  • Loading branch information...
commit e4c87a5df353c3f797d08dba344b511c347de293 1 parent 3a6c265
@cstamas cstamas authored
View
14 nexus/nexus-core/src/main/java/org/sonatype/nexus/proxy/maven/metadata/operations/SetSnapshotOperation.java
@@ -21,21 +21,25 @@
/**
* adds new snapshot to metadata
- *
+ *
* @author Oleg Gusakov
* @version $Id: SetSnapshotOperation.java 743040 2009-02-10 18:20:26Z ogusakov $
*/
public class SetSnapshotOperation
implements MetadataOperation
{
+
private SnapshotOperand operand;
+ private final VersionComparator versionComparator;
+
/**
* @throws MetadataException
*/
public SetSnapshotOperation( SnapshotOperand data )
throws MetadataException
{
+ this.versionComparator = new VersionComparator();
setOperand( data );
}
@@ -45,14 +49,14 @@ public void setOperand( AbstractOperand data )
if ( data == null || !( data instanceof SnapshotOperand ) )
{
throw new MetadataException( "Operand is not correct: expected SnapshotOperand, but got "
- + ( data == null ? "null" : data.getClass().getName() ) );
+ + ( data == null ? "null" : data.getClass().getName() ) );
}
this.operand = (SnapshotOperand) data;
}
/**
* add/replace snapshot to the in-memory metadata instance
- *
+ *
* @param metadata
* @return
* @throws MetadataException
@@ -104,7 +108,7 @@ private boolean updateSnapshot( Metadata metadata )
}
else
{
- if ( new VersionComparator().compare( current.getVersion(), extra.getVersion() ) < 0 )
+ if ( versionComparator.compare( current.getVersion(), extra.getVersion() ) < 0 )
{
currents.remove( current );
currents.add( extra );
@@ -112,7 +116,7 @@ private boolean updateSnapshot( Metadata metadata )
}
}
}
- else if ( Version.V100 == operand.getOriginModelVersion() )
+ else if ( Version.V100 == operand.getOriginModelVersion() && operand.getSnapshot() != null )
{
for ( SnapshotVersion current : currents )
{
Please sign in to comment.
Something went wrong with that request. Please try again.