提交 4825967f 编写于 作者: J Jesse Glick

Deleting code using @IgnoreJRERequirement for Java 5 compatibility.

上级 24052ea5
......@@ -32,7 +32,6 @@ import hudson.remoting.RemoteInputStream;
import hudson.remoting.RemoteOutputStream;
import hudson.remoting.SocketInputStream;
import hudson.remoting.SocketOutputStream;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
......@@ -592,10 +591,7 @@ public class CLI {
return pemString.contains("4,ENCRYPTED");
}
@SuppressWarnings("Since15")
@IgnoreJRERequirement
private static String askForPasswd(String filePath){
try {
Console cons = System.console();
String passwd = null;
if (cons != null){
......@@ -603,9 +599,6 @@ public class CLI {
passwd = String.valueOf(p);
}
return passwd;
} catch (LinkageError e) {
throw new Error("Your private key is encrypted, but we need Java6 to ask you password safely",e);
}
}
/**
......
......@@ -140,7 +140,6 @@ import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jexl.parser.ASTSizeFunction;
import org.apache.commons.jexl.util.Introspector;
import org.apache.commons.lang.StringUtils;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.jvnet.tiger_types.Types;
import org.kohsuke.stapler.Ancestor;
import org.kohsuke.stapler.Stapler;
......@@ -1126,7 +1125,6 @@ public class Functions {
return sorted;
}
@IgnoreJRERequirement
public static ThreadInfo[] getThreadInfos() {
ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
return mbean.dumpAllThreads(mbean.isObjectMonitorUsageSupported(),mbean.isSynchronizerUsageSupported());
......@@ -1190,20 +1188,14 @@ public class Functions {
}
/**
* Are we running on JRE6 or above?
* @deprecated Now always true.
*/
@IgnoreJRERequirement
@Deprecated
public static boolean isMustangOrAbove() {
try {
System.console();
return true;
} catch(LinkageError e) {
return false;
}
return true;
}
// ThreadInfo.toString() truncates the stack trace by first 8, so needed my own version
@IgnoreJRERequirement
public static String dumpThreadInfo(ThreadInfo ti, ThreadGroupMap map) {
String grp = map.getThreadGroup(ti);
StringBuilder sb = new StringBuilder("\"" + ti.getThreadName() + "\"" +
......
......@@ -42,7 +42,6 @@ import org.apache.tools.ant.taskdefs.Copy;
import org.apache.tools.ant.types.FileSet;
import jnr.posix.FileStat;
import jnr.posix.POSIX;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
......@@ -259,16 +258,11 @@ public class Util {
/**
* Makes the given file writable by any means possible.
*/
@IgnoreJRERequirement
private static void makeWritable(File f) {
// try JDK6-way of doing it.
try {
if (f.setWritable(true)) {
return;
}
} catch (NoSuchMethodError e) {
// not JDK6
if (f.setWritable(true)) {
return;
}
// TODO do we still need to try anything else?
// try chmod. this becomes no-op if this is not Unix.
try {
......@@ -1378,17 +1372,9 @@ public class Util {
* Loads a key/value pair string as {@link Properties}
* @since 1.392
*/
@IgnoreJRERequirement
public static Properties loadProperties(String properties) throws IOException {
Properties p = new Properties();
try {
p.load(new StringReader(properties));
} catch (NoSuchMethodError e) {
// load(Reader) method is only available on JDK6.
// this fall back version doesn't work correctly with non-ASCII characters,
// but there's no other easy ways out it seems.
p.load(new ByteArrayInputStream(properties.getBytes()));
}
p.load(new StringReader(properties));
return p;
}
......
......@@ -26,7 +26,6 @@ package hudson.diagnosis;
import hudson.Extension;
import jenkins.model.Jenkins;
import hudson.model.PeriodicWork;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import java.util.logging.Logger;
......@@ -42,9 +41,7 @@ public class HudsonHomeDiskUsageChecker extends PeriodicWork {
return HOUR;
}
@IgnoreJRERequirement
protected void doRun() {
try {
long free = Jenkins.getInstance().getRootDir().getUsableSpace();
long total = Jenkins.getInstance().getRootDir().getTotalSpace();
if(free<=0 || total<=0) {
......@@ -61,11 +58,6 @@ public class HudsonHomeDiskUsageChecker extends PeriodicWork {
// it's AND and not OR so that small Hudson home won't get a warning,
// and similarly, if you have a 1TB disk, you don't get a warning when you still have 100GB to go.
HudsonHomeDiskUsageMonitor.get().activated = (total/free>10 && free< FREE_SPACE_THRESHOLD);
} catch (LinkageError _) {
// pre Mustang
LOGGER.info("Not on JDK6. Cannot monitor JENKINS_HOME disk usage");
cancel();
}
}
private static final Logger LOGGER = Logger.getLogger(HudsonHomeDiskUsageChecker.class.getName());
......
......@@ -25,7 +25,6 @@ package hudson.node_monitors;
import hudson.Extension;
import hudson.FilePath;
import hudson.Functions;
import hudson.model.Computer;
import hudson.remoting.Callable;
import jenkins.model.Jenkins;
......@@ -76,7 +75,6 @@ public class DiskSpaceMonitor extends AbstractDiskSpaceMonitor {
@Extension
public static DiskSpaceMonitorDescriptor install() {
if(Functions.isMustangOrAbove()) return DESCRIPTOR;
return null;
return DESCRIPTOR;
}
}
......@@ -24,12 +24,10 @@
package hudson.node_monitors;
import hudson.FilePath.FileCallable;
import hudson.model.Computer;
import hudson.remoting.VirtualChannel;
import hudson.Util;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.DiskSpaceMonitorDescriptor.DiskSpace;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import java.io.File;
import java.io.IOException;
......@@ -161,16 +159,10 @@ public abstract class DiskSpaceMonitorDescriptor extends AbstractAsyncNodeMonito
protected static final class GetUsableSpace implements FileCallable<DiskSpace> {
public GetUsableSpace() {}
@IgnoreJRERequirement
public DiskSpace invoke(File f, VirtualChannel channel) throws IOException {
try {
long s = f.getUsableSpace();
if(s<=0) return null;
return new DiskSpace(f.getCanonicalPath(), s);
} catch (LinkageError e) {
// pre-mustang
return null;
}
}
private static final long serialVersionUID = 1L;
}
......
......@@ -26,13 +26,11 @@ package hudson.node_monitors;
import hudson.Extension;
import hudson.FilePath;
import hudson.FilePath.FileCallable;
import hudson.Functions;
import hudson.model.Computer;
import hudson.remoting.Callable;
import jenkins.model.Jenkins;
import hudson.node_monitors.DiskSpaceMonitorDescriptor.DiskSpace;
import hudson.remoting.VirtualChannel;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.kohsuke.stapler.DataBoundConstructor;
import java.io.File;
......@@ -78,24 +76,17 @@ public class TemporarySpaceMonitor extends AbstractDiskSpaceMonitor {
@Extension
public static DiskSpaceMonitorDescriptor install() {
if(Functions.isMustangOrAbove()) return DESCRIPTOR;
return null;
return DESCRIPTOR;
}
protected static final class GetTempSpace implements FileCallable<DiskSpace> {
@IgnoreJRERequirement
public DiskSpace invoke(File f, VirtualChannel channel) throws IOException {
try {
// if the disk is really filled up we can't even create a single file,
// so calling File.createTempFile and figuring out the directory won't reliably work.
f = new File(System.getProperty("java.io.tmpdir"));
long s = f.getUsableSpace();
if(s<=0) return null;
return new DiskSpace(f.getCanonicalPath(), s);
} catch (LinkageError e) {
// pre-mustang
return null;
}
}
private static final long serialVersionUID = 1L;
}
......
......@@ -15,7 +15,6 @@ import org.acegisecurity.providers.dao.AbstractUserDetailsAuthenticationProvider
import org.acegisecurity.userdetails.UserDetails;
import org.acegisecurity.userdetails.UserDetailsService;
import org.acegisecurity.userdetails.UsernameNotFoundException;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.kohsuke.args4j.Option;
import org.springframework.dao.DataAccessException;
import org.springframework.web.context.WebApplicationContext;
......@@ -141,7 +140,6 @@ public abstract class AbstractPasswordBasedSecurityRealm extends SecurityRealm i
* Asks for the password.
*/
private static class InteractivelyAskForPassword implements Callable<String,IOException> {
@IgnoreJRERequirement
public String call() throws IOException {
Console console = System.console();
if (console == null) return null; // no terminal
......
......@@ -30,12 +30,10 @@ import hudson.FilePath.FileCallable;
import hudson.ProxyConfiguration;
import hudson.Util;
import hudson.Functions;
import hudson.os.PosixAPI;
import hudson.model.Node;
import hudson.model.TaskListener;
import hudson.remoting.VirtualChannel;
import hudson.util.FormValidation;
import hudson.util.jna.GNUCLibrary;
import java.io.File;
import java.io.IOException;
......@@ -45,7 +43,6 @@ import java.net.URL;
import java.net.URLConnection;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
/**
* Installs a tool into the Hudson working area by downloading and unpacking a ZIP file.
......@@ -126,20 +123,9 @@ public class ZipExtractionInstaller extends ToolInstaller {
process(d);
return null;
}
@IgnoreJRERequirement
private void process(File f) {
if (f.isFile()) {
if(Functions.isMustangOrAbove())
f.setExecutable(true, false);
else {
try {
GNUCLibrary.LIBC.chmod(f.getAbsolutePath(),0755);
} catch (LinkageError e) {
// if JNA is unavailable, fall back.
// we still prefer to try JNA first as PosixAPI supports even smaller platforms.
PosixAPI.jnr().chmod(f.getAbsolutePath(),0755);
}
}
f.setExecutable(true, false);
} else {
File[] kids = f.listFiles();
if (kids != null) {
......
......@@ -92,21 +92,10 @@ public final class RemotingDiagnostics {
private static final class GetThreadDump implements Callable<Map<String,String>,RuntimeException> {
public Map<String,String> call() {
Map<String,String> r = new LinkedHashMap<String,String>();
try {
ThreadInfo[] data = Functions.getThreadInfos();
Functions.ThreadGroupMap map = Functions.sortThreadsAndGetGroupMap(data);
for (ThreadInfo ti : data)
r.put(ti.getThreadName(),Functions.dumpThreadInfo(ti,map));
} catch (LinkageError _) {
// not in JDK6. fall back to JDK5
r.clear();
for (Map.Entry<Thread,StackTraceElement[]> t : Functions.dumpAllThreads().entrySet()) {
StringBuilder buf = new StringBuilder();
for (StackTraceElement e : t.getValue())
buf.append(e).append('\n');
r.put(t.getKey().getName(),buf.toString());
}
}
return r;
}
private static final long serialVersionUID = 1L;
......
......@@ -24,7 +24,6 @@
package jenkins;
import hudson.Plugin;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.kohsuke.MetaInfServices;
import javax.annotation.processing.AbstractProcessor;
......@@ -58,7 +57,6 @@ import java.util.Set;
@SupportedSourceVersion(SourceVersion.RELEASE_6)
@SupportedAnnotationTypes("*")
@MetaInfServices(Processor.class)
@IgnoreJRERequirement
@SuppressWarnings({"Since15"})
public class PluginSubtypeMarker extends AbstractProcessor {
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册