|  | 
| 123 | 123 | import org.slf4j.LoggerFactory; | 
| 124 | 124 | 
 | 
| 125 | 125 | import java.io.File; | 
|  | 126 | +import java.io.FileOutputStream; | 
|  | 127 | +import java.io.InputStream; | 
| 126 | 128 | import java.lang.reflect.Field; | 
| 127 | 129 | import java.net.InetSocketAddress; | 
| 128 | 130 | import java.net.URL; | 
|  | 131 | +import java.nio.file.Files; | 
|  | 132 | +import java.nio.file.Path; | 
| 129 | 133 | import java.util.ArrayList; | 
| 130 | 134 | import java.util.Arrays; | 
| 131 | 135 | import java.util.Collection; | 
| @@ -366,9 +370,19 @@ private void applyJettyConfiguration() throws Exception { | 
| 366 | 370 | 			// PAXWEB-1112: TCCL to perform static initialization of XmlConfiguration with proper TCCL | 
| 367 | 371 | 			// needed for org.eclipse.jetty.xml.XmlConfiguration.__factoryLoader | 
| 368 | 372 | 			Thread.currentThread().setContextClassLoader(jettyXmlCl); | 
| 369 |  | -			URL emptyConfig = getClass().getResource("/jetty-empty.xml"); | 
| 370 |  | -			if (emptyConfig != null) { | 
| 371 |  | -				new XmlConfiguration(jettyFactory.newResource(emptyConfig)); | 
|  | 373 | +			String emptyConfigFile = "jetty-empty.xml"; | 
|  | 374 | +			try (InputStream inStream = getClass().getResourceAsStream("/" + emptyConfigFile)) { | 
|  | 375 | +				if (inStream != null) { | 
|  | 376 | +					Path emptyConfig = Files.createTempFile(emptyConfigFile, ".tmp"); | 
|  | 377 | +					try (FileOutputStream outStream = new FileOutputStream(new File(emptyConfig.toUri()))) { | 
|  | 378 | +						inStream.transferTo(outStream); | 
|  | 379 | +						new XmlConfiguration(jettyFactory.newResource(emptyConfig.toUri().toURL())); | 
|  | 380 | +					} finally { | 
|  | 381 | +						// the tmp file can be safely deleted as it was only used to initialize XmlConfiguration, | 
|  | 382 | +						// and no actual configuration will be applied from it | 
|  | 383 | +						Files.delete(emptyConfig); | 
|  | 384 | +					} | 
|  | 385 | +				} | 
| 372 | 386 | 			} | 
| 373 | 387 | 
 | 
| 374 | 388 | 			// to load HttpFieldPreEncoder both for HTTP/1.1 and HTTP/2 we need to call static block | 
|  | 
0 commit comments