Skip to content

Commit

Permalink
chore: Remove code-paths for Java versions <=8 (#7297)
Browse files Browse the repository at this point in the history
  • Loading branch information
aikebah authored Jan 11, 2025
1 parent b51921f commit 0fd289a
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 609 deletions.
4 changes: 0 additions & 4 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,6 @@ Copyright (c) 2012 Jeremy Long. All Rights Reserved.
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-afterburner</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-blackbird</artifactId>
Expand Down
16 changes: 0 additions & 16 deletions core/src/main/java/org/owasp/dependencycheck/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
import static org.owasp.dependencycheck.analyzer.AnalysisPhase.PRE_INFORMATION_COLLECTION;
import org.owasp.dependencycheck.analyzer.DependencyBundlingAnalyzer;
import org.owasp.dependencycheck.dependency.naming.Identifier;
import org.owasp.dependencycheck.utils.Utils;

/**
* Scans files, directories, etc. for Dependencies. Analyzers are loaded and
Expand Down Expand Up @@ -191,8 +190,6 @@ public Engine(@NotNull final ClassLoader serviceClassLoader, @NotNull final Mode
this.mode = mode;
this.accessExternalSchema = System.getProperty("javax.xml.accessExternalSchema");

checkRuntimeVersion();

initializeEngine();
}

Expand Down Expand Up @@ -1286,19 +1283,6 @@ private boolean identifiersMatch(Set<Identifier> left, Set<Identifier> right) {
return false;
}

/**
* Checks that if Java 8 is being used, it is at least update 251. This is
* required as a new method was introduced that is used by Apache HTTP
* Client. See
* https://stackoverflow.com/questions/76226322/exception-in-thread-httpclient-dispatch-1-java-lang-nosuchmethoderror-javax-n#comment134427003_76226322
*/
private void checkRuntimeVersion() {
if (Utils.getJavaVersion() == 8 && Utils.getJavaUpdateVersion() < 251) {
LOGGER.error("Non-supported Java Runtime: dependency-check requires at least Java 8 update 251 or higher.");
throw new RuntimeException("dependency-check requires Java 8 update 251 or higher");
}
}

/**
* {@link Engine} execution modes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
import com.fasterxml.jackson.module.blackbird.BlackbirdModule;
import java.io.EOFException;
import java.io.IOException;
Expand All @@ -33,7 +31,6 @@
import org.owasp.dependencycheck.data.knownexploited.json.KnownExploitedVulnerabilitiesSchema;
import org.owasp.dependencycheck.data.update.exception.CorruptedDatastreamException;
import org.owasp.dependencycheck.data.update.exception.UpdateException;
import org.owasp.dependencycheck.utils.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -61,13 +58,7 @@ public class KnownExploitedVulnerabilityParser {
public KnownExploitedVulnerabilitiesSchema parse(InputStream in) throws UpdateException, CorruptedDatastreamException {

final ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
final Module module;
if (Utils.getJavaVersion() <= 8) {
module = new AfterburnerModule();
} else {
module = new BlackbirdModule();
}
objectMapper.registerModule(module);
objectMapper.registerModule(new BlackbirdModule());

final ObjectReader objectReader = objectMapper.readerFor(KnownExploitedVulnerabilitiesSchema.class);

Expand Down
120 changes: 0 additions & 120 deletions core/src/main/java/org/owasp/dependencycheck/utils/Utils.java

This file was deleted.

61 changes: 0 additions & 61 deletions core/src/test/java/org/owasp/dependencycheck/utils/UtilsTest.java

This file was deleted.

Loading

0 comments on commit 0fd289a

Please sign in to comment.