Skip to content

Commit

Permalink
Remove ZipError usage which is dead code since JDK 9 (JDK-8336843).
Browse files Browse the repository at this point in the history
 - CachingArchive catches Exception from now on which seems to be
   the safest approach
 - removed the ZipError handler from NexusRepositoryIndexerImpl since
   the section is inside a repo mutex and MutexExceptions are already
   handled
  • Loading branch information
mbien committed Oct 11, 2024
1 parent ed97fb6 commit 88475d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -39,7 +38,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipError;
import java.util.zip.ZipFile;
import javax.lang.model.SourceVersion;
import javax.tools.JavaFileObject;
Expand Down Expand Up @@ -363,12 +361,12 @@ private Map<String,Folder> createMap(File file ) throws IOException {
entry = e.nextElement();
} catch (IllegalArgumentException iae) {
throw new IOException(iae);
} catch (ZipError ze) {
} catch (Exception ex) {
// the JAR may be corrupted somehow; no further entry read
// will probably succeed, so just skip the rest of the jar.
Exceptions.printStackTrace(
Exceptions.attachLocalizedMessage(
Exceptions.attachSeverity(ze, Level.WARNING),
Exceptions.attachSeverity(ex, Level.WARNING),
Bundle.ERR_CorruptedZipFile(file)));
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import java.util.zip.ZipError;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.Term;
Expand Down Expand Up @@ -886,10 +885,8 @@ public void updateIndexWithArtifacts(final RepositoryInfo repo, final Collection
BooleanQuery bq = new BooleanQuery.Builder()
.add(new BooleanClause(new PrefixQuery(new Term(ArtifactInfo.UINFO, id)), BooleanClause.Occur.MUST))
.build();
IteratorSearchResponse response = repeatedPagedSearch(bq, indexingContext, MAX_RESULT_COUNT);
add = response == null || response.getTotalHitsCount() == 0;
if (response != null) {
response.close();
try (IteratorSearchResponse response = repeatedPagedSearch(bq, indexingContext, MAX_RESULT_COUNT)) {
add = response == null || response.getTotalHitsCount() == 0;
}
}
if (add) {
Expand All @@ -903,17 +900,16 @@ public void updateIndexWithArtifacts(final RepositoryInfo repo, final Collection
}

}
try {
indexer.addArtifactsToIndex(artifactContexts, indexingContext);
storeGroupCache(repo, indexingContext);
} catch (ZipError err) {
LOGGER.log(Level.INFO, "#230581 concurrent access to local repository file. Skipping..", err);
}
indexer.addArtifactsToIndex(artifactContexts, indexingContext);
storeGroupCache(repo, indexingContext);

return null;
});
} catch (MutexException ex) {
Exceptions.printStackTrace(ex);
List<Artifact> sample = artifacts.stream().limit(5).toList();
LOGGER.log(Level.WARNING,
"Unable to update index with artifact(s): " + sample
+ (artifacts.size() > sample.size() ? (" +" + (artifacts.size() - sample.size()) + " more") : ""), ex);
} catch (NullPointerException x) {
LOGGER.log(Level.INFO, "#201057", x);
}
Expand Down

0 comments on commit 88475d3

Please sign in to comment.