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

Log deprecation warning when using deprecated hudson.remoting.jnlp.Main entrypoint #695

Merged
merged 1 commit into from
Oct 26, 2023
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
37 changes: 36 additions & 1 deletion src/main/java/hudson/remoting/jnlp/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
package hudson.remoting.jnlp;

import hudson.remoting.Launcher;
import java.io.IOException;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import org.kohsuke.args4j.CmdLineException;
import org.xml.sax.SAXException;

/**
* Previous entry point to pseudo-JNLP agent.
Expand All @@ -34,4 +39,34 @@
* @deprecated use {@link Launcher}
*/
@Deprecated
public class Main extends Launcher {}
public class Main extends Launcher {

private static volatile boolean deprecationWarningLogged;

public static void main(String... args) throws IOException, InterruptedException {
logDeprecation();
Launcher.main(args);
}

@Override
public void run() throws CmdLineException, IOException, InterruptedException {
logDeprecation();
super.run();
}

@Override
public List<String> parseJnlpArguments()
throws ParserConfigurationException, SAXException, IOException, InterruptedException {
logDeprecation();
return super.parseJnlpArguments();
}

private static void logDeprecation() {
if (deprecationWarningLogged) {
return;
}
System.err.println(
"WARNING: Using deprecated entrypoint \"java -cp agent.jar hudson.remoting.jnlp.Main\". Use \"java -jar agent.jar\" instead.");
deprecationWarningLogged = true;
}
}
Loading