Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unclosed opened stream #105

Merged
merged 1 commit into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ public ArtifactStoreFileSystem( ArtifactStore store )
this.store = store;
}

/**
* {@inheritDoc}
*/
@Override
public Entry[] listEntries( DirectoryEntry directory )
{
if ( getRoot().equals( directory ) )
Expand Down Expand Up @@ -164,7 +162,6 @@ public Entry[] listEntries( DirectoryEntry directory )
String groupId = path.replace( '/', '.' );

// get all the groupId's that start with this groupId
String groupIdPrefix = groupId + ".";
Set<String> groupIds = new TreeSet<>( store.getGroupIds( groupId ) );
for ( String name : groupIds )
{
Expand Down Expand Up @@ -223,9 +220,7 @@ public Entry[] listEntries( DirectoryEntry directory )
return result.toArray(new Entry[0]);
}

/**
* {@inheritDoc}
*/
@Override
protected Entry get( DirectoryEntry parent, String name )
{
String path = "/";
Expand Down Expand Up @@ -299,7 +294,8 @@ else if ( ARCHETYPE_CATALOG.matcher( path ).matches() )
matcher.group( 10 ) );
try
{
store.get( artifact );
// check if artifact exist
store.getSize( artifact );
return new ArtifactFileEntry( this, parent, artifact, store );
}
catch ( IOException | ArtifactNotFoundException e )
Expand All @@ -325,7 +321,8 @@ else if ( ARCHETYPE_CATALOG.matcher( path ).matches() )
matcher.group( 10 ), timestamp, buildNumber );
try
{
store.get( artifact );
// check if artifact exist
store.getSize( artifact );
return new ArtifactFileEntry( this, parent, artifact, store );
}
catch ( IOException | ArtifactNotFoundException e )
Expand Down Expand Up @@ -360,7 +357,8 @@ else if ( ARCHETYPE_CATALOG.matcher( path ).matches() )
Artifact artifact = new Artifact( groupId, artifactId, version, classifier, type );
try
{
store.get( artifact );
// check if artifact exist
store.getSize( artifact );
return new ArtifactFileEntry( this, parent, artifact, store );
}
catch ( ArtifactNotFoundException | IOException e )
Expand All @@ -376,9 +374,7 @@ else if ( ARCHETYPE_CATALOG.matcher( path ).matches() )
}
}

/**
* {@inheritDoc}
*/
@Override
public long getLastModified( DirectoryEntry entry )
throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class ArtifactStoreFileSystemTest

@Test
public void testGroupMetadataRegex()
throws Exception
{
Matcher matcher = ArtifactStoreFileSystem.METADATA.matcher( "/commons/maven-metadata.xml" );
assertTrue( matcher.matches() );
Expand All @@ -56,7 +55,6 @@ public void testGroupMetadataRegex()

@Test
public void testArtifactRegex()
throws Exception
{
Matcher matcher = ArtifactStoreFileSystem.ARTIFACT.matcher( "/commons/maven-metadata.xml" );
assertFalse( matcher.matches() );
Expand Down Expand Up @@ -109,7 +107,6 @@ public void testArtifactRegex()

@Test
public void testSnapshotArtifactRegex()
throws Exception
{
Matcher matcher = ArtifactStoreFileSystem.SNAPSHOT_ARTIFACT.matcher( "/commons/maven-metadata.xml" );
assertFalse( matcher.matches() );
Expand Down Expand Up @@ -159,7 +156,7 @@ public void testSnapshotArtifactRegex()
public void testSiteXmlReleaseVersion() throws Exception
{
ArtifactStore store = mock( ArtifactStore.class );
when( store.get( isA( Artifact.class ) ) ).thenThrow( ArtifactNotFoundException.class );
when( store.getSize( isA( Artifact.class ) ) ).thenThrow( ArtifactNotFoundException.class );
ArtifactStoreFileSystem system = new ArtifactStoreFileSystem( store );
FileEntry entry = (FileEntry) system.get( "/localhost/mmockrm-5/1/mmockrm-5-1-site_en.xml" );
assertNull( entry );
Expand All @@ -169,7 +166,7 @@ public void testSiteXmlReleaseVersion() throws Exception
public void testSiteXmlSnapshotVersion() throws Exception
{
ArtifactStore store = mock( ArtifactStore.class );
when( store.get( isA( Artifact.class ) ) ).thenThrow( ArtifactNotFoundException.class );
when( store.getSize( isA( Artifact.class ) ) ).thenThrow( ArtifactNotFoundException.class );
ArtifactStoreFileSystem system = new ArtifactStoreFileSystem( store );
FileEntry entry = (FileEntry) system.get( "/localhost/mmockrm-5/1.0-SNAPSHOT/mmockrm-5-1.0-SNAPSHOT-site_en.xml" );
assertNull( entry );
Expand Down