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

DPE-443: Fix Jetty wrapper configuration at startup #27

Merged
merged 5 commits into from
Nov 28, 2024
Merged
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 @@ -123,9 +123,13 @@
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.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 +370,19 @@ 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));
String emptyConfigFile = "jetty-empty.xml";
try (InputStream inStream = getClass().getResourceAsStream("/" + emptyConfigFile)) {
if (inStream != null) {
Path emptyConfig = Files.createTempFile(emptyConfigFile, ".tmp");
try (FileOutputStream outStream = new FileOutputStream(new File(emptyConfig.toUri()))) {
inStream.transferTo(outStream);
new XmlConfiguration(jettyFactory.newResource(emptyConfig.toUri().toURL()));
} finally {
// the tmp file can be safely deleted as it was only used to initialize XmlConfiguration,
// and no actual configuration will be applied from it
Files.delete(emptyConfig);
}
}
}

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