Skip to content

Commit

Permalink
DPE-443: fix jetty startup
Browse files Browse the repository at this point in the history
  • Loading branch information
stataru8 committed Nov 26, 2024
1 parent cff719d commit be8ad34
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,14 @@
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -366,9 +371,16 @@ private void applyJettyConfiguration() throws Exception {
// PAXWEB-1112: TCCL to perform static initialization of XmlConfiguration with proper TCCL
// needed for org.eclipse.jetty.xml.XmlConfiguration.__factoryLoader
Thread.currentThread().setContextClassLoader(jettyXmlCl);
URL emptyConfig = getClass().getResource("/jetty-empty.xml");
if (emptyConfig != null) {
new XmlConfiguration(jettyFactory.newResource(emptyConfig));
try (InputStream inStream = getClass().getResourceAsStream("/jetty-empty.xml")) {
if (inStream != null) {
Path emptyConfig = Files.createTempFile(getClass().getName(), ".tmp");
try (FileOutputStream outStream = new FileOutputStream(new File(emptyConfig.toUri()))) {
inStream.transferTo(outStream);
new XmlConfiguration(jettyFactory.newResource(emptyConfig.toUri().toURL()));
} finally {
Files.delete(emptyConfig);
}
}
}

// to load HttpFieldPreEncoder both for HTTP/1.1 and HTTP/2 we need to call static block
Expand Down

0 comments on commit be8ad34

Please sign in to comment.