Skip to content

Commit a1a87f5

Browse files
authored
Merge pull request #7862 from mbien/remove-ziperror-usage
Remove ZipError usage which is dead code since JDK 9 (JDK-8336843).
2 parents d28a518 + 88475d3 commit a1a87f5

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

java/java.source.base/src/org/netbeans/modules/java/source/parsing/CachingArchive.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.io.IOException;
2626
import java.io.InputStream;
2727
import java.net.URI;
28-
import java.net.URISyntaxException;
2928
import java.nio.charset.StandardCharsets;
3029
import java.util.ArrayList;
3130
import java.util.Collections;
@@ -39,7 +38,6 @@
3938
import java.util.logging.Level;
4039
import java.util.logging.Logger;
4140
import java.util.zip.ZipEntry;
42-
import java.util.zip.ZipError;
4341
import java.util.zip.ZipFile;
4442
import javax.lang.model.SourceVersion;
4543
import javax.tools.JavaFileObject;
@@ -363,12 +361,12 @@ private Map<String,Folder> createMap(File file ) throws IOException {
363361
entry = e.nextElement();
364362
} catch (IllegalArgumentException iae) {
365363
throw new IOException(iae);
366-
} catch (ZipError ze) {
364+
} catch (Exception ex) {
367365
// the JAR may be corrupted somehow; no further entry read
368366
// will probably succeed, so just skip the rest of the jar.
369367
Exceptions.printStackTrace(
370368
Exceptions.attachLocalizedMessage(
371-
Exceptions.attachSeverity(ze, Level.WARNING),
369+
Exceptions.attachSeverity(ex, Level.WARNING),
372370
Bundle.ERR_CorruptedZipFile(file)));
373371
break;
374372
}

java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import java.util.regex.Matcher;
4545
import java.util.regex.Pattern;
4646
import java.util.stream.Stream;
47-
import java.util.zip.ZipError;
4847
import org.apache.lucene.index.DirectoryReader;
4948
import org.apache.lucene.index.IndexableField;
5049
import org.apache.lucene.index.Term;
@@ -886,10 +885,8 @@ public void updateIndexWithArtifacts(final RepositoryInfo repo, final Collection
886885
BooleanQuery bq = new BooleanQuery.Builder()
887886
.add(new BooleanClause(new PrefixQuery(new Term(ArtifactInfo.UINFO, id)), BooleanClause.Occur.MUST))
888887
.build();
889-
IteratorSearchResponse response = repeatedPagedSearch(bq, indexingContext, MAX_RESULT_COUNT);
890-
add = response == null || response.getTotalHitsCount() == 0;
891-
if (response != null) {
892-
response.close();
888+
try (IteratorSearchResponse response = repeatedPagedSearch(bq, indexingContext, MAX_RESULT_COUNT)) {
889+
add = response == null || response.getTotalHitsCount() == 0;
893890
}
894891
}
895892
if (add) {
@@ -903,17 +900,16 @@ public void updateIndexWithArtifacts(final RepositoryInfo repo, final Collection
903900
}
904901

905902
}
906-
try {
907-
indexer.addArtifactsToIndex(artifactContexts, indexingContext);
908-
storeGroupCache(repo, indexingContext);
909-
} catch (ZipError err) {
910-
LOGGER.log(Level.INFO, "#230581 concurrent access to local repository file. Skipping..", err);
911-
}
903+
indexer.addArtifactsToIndex(artifactContexts, indexingContext);
904+
storeGroupCache(repo, indexingContext);
912905

913906
return null;
914907
});
915908
} catch (MutexException ex) {
916-
Exceptions.printStackTrace(ex);
909+
List<Artifact> sample = artifacts.stream().limit(5).toList();
910+
LOGGER.log(Level.WARNING,
911+
"Unable to update index with artifact(s): " + sample
912+
+ (artifacts.size() > sample.size() ? (" +" + (artifacts.size() - sample.size()) + " more") : ""), ex);
917913
} catch (NullPointerException x) {
918914
LOGGER.log(Level.INFO, "#201057", x);
919915
}

0 commit comments

Comments
 (0)