From cb7f8f670748e9675a0688fa542314cff184a48b Mon Sep 17 00:00:00 2001 From: "amine.chbari.etu" <amine@DESKTOP-QK66G6C> Date: Fri, 5 Apr 2024 22:25:43 +0200 Subject: [PATCH] renommer l'exception en LaunchErrorException, et ajouter l'implementation de cette exception dans le package exception/ --- .../main/java/org/red5/server/Launcher.java | 13 ++++++++---- .../exception/LaunchErrorException.java | 21 +++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 server/src/main/java/org/red5/server/exception/LaunchErrorException.java diff --git a/server/src/main/java/org/red5/server/Launcher.java b/server/src/main/java/org/red5/server/Launcher.java index 27d27ad5..2885fe62 100644 --- a/server/src/main/java/org/red5/server/Launcher.java +++ b/server/src/main/java/org/red5/server/Launcher.java @@ -9,6 +9,7 @@ package org.red5.server; import org.red5.logging.Red5LoggerFactory; import org.red5.server.api.Red5; +import org.red5.server.exception.LaunchErrorException; import org.slf4j.Logger; import org.slf4j.bridge.SLF4JBridgeHandler; import org.springframework.context.support.FileSystemXmlApplicationContext; @@ -26,10 +27,10 @@ public class Launcher { /** * Launch Red5 under it's own classloader * - * @throws Exception + * @throws LaunchErrorException * on error */ - public void launch() throws Exception { + public void launch() throws LaunchErrorException { System.out.printf("Root: %s%nDeploy type: %s%n", System.getProperty(l_root), System.getProperty("red5.deployment.type")); // check for the logback disable flag boolean useLogback = Boolean.valueOf(System.getProperty("useLogback", "true")); @@ -52,8 +53,12 @@ public class Launcher { // create red5 app context @SuppressWarnings("resource") FileSystemXmlApplicationContext root = new FileSystemXmlApplicationContext(new String[] { "classpath:/red5.xml" }, false); - // set the current threads classloader as the loader for the factory/appctx - root.setClassLoader(Thread.currentThread().getContextClassLoader()); + try { + // set the current threads classloader as the loader for the factory/appctx + root.setClassLoader(Thread.currentThread().getContextClassLoader()); + } catch (Exception e) { + throw new LaunchErrorException("possible mismatch between the classloader used to launch the application and the one expected by the context ", e); + } root.setId(l_root); root.setBeanName(l_root); // refresh must be called before accessing the bean factory diff --git a/server/src/main/java/org/red5/server/exception/LaunchErrorException.java b/server/src/main/java/org/red5/server/exception/LaunchErrorException.java new file mode 100644 index 00000000..f10f140f --- /dev/null +++ b/server/src/main/java/org/red5/server/exception/LaunchErrorException.java @@ -0,0 +1,21 @@ +/* + * RED5 Open Source Media Server - https://github.com/Red5/ Copyright 2006-2023 by respective authors (see below). All rights reserved. Licensed under the Apache License, Version + * 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless + * required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ +package org.red5.server.exception; +/** +* Couldn't launch the server +* +*/ +public class LaunchErrorException extends Exception{ + + /** + * this is serial Version is required from the owner developer that owns the right to initialize it + */ + // private static final long serialVersionUID = /* TODO */; + public LaunchErrorException(String message, Throwable cause) { + super(message, cause); + } +} \ No newline at end of file -- GitLab