You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2022/10/08 15:05:29 UTC

[juneau] branch master updated: Upgrade to Jetty 9.4.49

This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new c051bbd40 Upgrade to Jetty 9.4.49
c051bbd40 is described below

commit c051bbd405b5f779b3d383a16a3ca158a70ca8f6
Author: JamesBognar <ja...@salesforce.com>
AuthorDate: Sat Oct 8 11:04:56 2022 -0400

    Upgrade to Jetty 9.4.49
---
 .../java/org/apache/juneau/internal/FileUtils.java | 24 ++++++++++++++++++++++
 .../jetty/BasicJettyServerFactory.java             |  9 +++++++-
 .../juneau-my-jetty-microservice/logs/empty.txt    |  0
 pom.xml                                            |  2 +-
 4 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FileUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FileUtils.java
index 3ed115aae..728f4e596 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FileUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FileUtils.java
@@ -147,6 +147,30 @@ public class FileUtils {
 		return f;
 	}
 
+	/**
+	 * Create a temporary file with the specified name and specified contents.
+	 *
+	 * <p>
+	 * The name is broken into file name and suffix, and the parts are passed to
+	 * {@link File#createTempFile(String, String)}.
+	 *
+	 * <p>
+	 * {@link File#deleteOnExit()} is called on the resulting file before being returned by this method.
+	 *
+	 * @param name The file name
+	 * @param contents The file contents.
+	 * @return A newly-created temporary file.
+	 * @throws IOException Thrown by underlying stream.
+	 */
+	public static File createTempFile(String name, String contents) throws IOException {
+		File f = createTempFile(name);
+		try (Reader r = new StringReader(contents); Writer w = new FileWriter(f)) {
+			IOUtils.pipe(r, w);
+			w.flush();
+		}
+		return f;
+	};
+
 	/**
 	 * Strips the extension from a file name.
 	 *
diff --git a/juneau-microservice/juneau-microservice-jetty/src/main/java/org/apache/juneau/microservice/jetty/BasicJettyServerFactory.java b/juneau-microservice/juneau-microservice-jetty/src/main/java/org/apache/juneau/microservice/jetty/BasicJettyServerFactory.java
index 093e43276..415dfde99 100644
--- a/juneau-microservice/juneau-microservice-jetty/src/main/java/org/apache/juneau/microservice/jetty/BasicJettyServerFactory.java
+++ b/juneau-microservice/juneau-microservice-jetty/src/main/java/org/apache/juneau/microservice/jetty/BasicJettyServerFactory.java
@@ -14,7 +14,9 @@ package org.apache.juneau.microservice.jetty;
 
 import java.io.*;
 
+import org.apache.juneau.internal.*;
 import org.eclipse.jetty.server.*;
+import org.eclipse.jetty.util.resource.*;
 import org.eclipse.jetty.xml.*;
 
 /**
@@ -31,7 +33,12 @@ public class BasicJettyServerFactory implements JettyServerFactory {
 	public Server create(String jettyXml) throws Exception {
 		if (jettyXml == null)
 			throw new RuntimeException("jetty.xml file location was not specified in the configuration file (Jetty/config) or manifest file (Jetty-Config) or found on the file system or classpath.");
-		XmlConfiguration xmlConfiguration = new XmlConfiguration(new ByteArrayInputStream(jettyXml.getBytes()));
+		File f = FileUtils.createTempFile("jetty.xml");
+		try (Reader r = new StringReader(jettyXml); Writer w = new FileWriter(f)) {
+			IOUtils.pipe(r, w);
+			w.flush();
+		}
+		XmlConfiguration xmlConfiguration = new XmlConfiguration(Resource.newResource(f));
 		return (Server)xmlConfiguration.configure();
 	}
 }
diff --git a/juneau-microservice/juneau-my-jetty-microservice/logs/empty.txt b/juneau-microservice/juneau-my-jetty-microservice/logs/empty.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/pom.xml b/pom.xml
index f3a472cd9..ef7543efb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,7 +41,7 @@
 		<servlet.version>4.0.1</servlet.version>
 		<httpcore.version>4.4.13</httpcore.version>
 		<httpclient.version>4.5.13</httpclient.version>
-		<jetty.version>9.4.13.v20181111</jetty.version>
+		<jetty.version>9.4.49.v20220914</jetty.version>
 		<juneau.compare.version>8.0.0</juneau.compare.version>
 		<javadoc.juneau.version>9.0.0</javadoc.juneau.version>
 		<juneauVersion>9.0.0</juneauVersion>