From 7143bf7c240f9bd4d10f05449e7fcda8f1e9c406 Mon Sep 17 00:00:00 2001 From: offa Date: Thu, 1 Jul 2021 17:15:05 +0200 Subject: [PATCH] Commented out code removed. --- .../java/hudson/ClassicPluginStrategy.java | 9 -------- core/src/main/java/hudson/Proc.java | 11 +--------- .../hudson/diagnosis/MemoryUsageMonitor.java | 8 ------- .../hudson/model/BuildTimelineWidget.java | 5 +---- .../main/java/hudson/model/Fingerprint.java | 19 ---------------- core/src/main/java/hudson/model/Job.java | 2 -- .../main/java/hudson/model/PageDecorator.java | 3 --- core/src/main/java/hudson/model/Run.java | 22 ------------------- core/src/main/java/hudson/model/Slave.java | 3 --- core/src/main/java/hudson/model/TreeView.java | 8 ------- .../hudson/model/queue/MappingWorksheet.java | 6 ----- .../AbstractNodeMonitorDescriptor.java | 2 -- .../node_monitors/ResponseTimeMonitor.java | 6 ----- .../security/BasicAuthenticationFilter.java | 14 ------------ .../java/hudson/util/ChunkedInputStream.java | 19 ---------------- .../main/java/hudson/util/ProcessTree.java | 19 ---------------- .../LastGrantedAuthoritiesProperty.java | 22 ------------------- .../jenkins/RemotingJarSignatureTest.java | 7 ++---- 18 files changed, 4 insertions(+), 181 deletions(-) diff --git a/core/src/main/java/hudson/ClassicPluginStrategy.java b/core/src/main/java/hudson/ClassicPluginStrategy.java index 19f04f0168..fd15af1a76 100644 --- a/core/src/main/java/hudson/ClassicPluginStrategy.java +++ b/core/src/main/java/hudson/ClassicPluginStrategy.java @@ -621,15 +621,6 @@ public class ClassicPluginStrategy implements PluginStrategy { return transientDependencies; } -// public List getDependencyPluginWrappers() { -// List r = new ArrayList(); -// for (Dependency d : dependencies) { -// PluginWrapper w = pluginManager.getPlugin(d.shortName); -// if (w!=null) r.add(w); -// } -// return r; -// } - @Override protected Class findClass(String name) throws ClassNotFoundException { if (PluginManager.FAST_LOOKUP) { diff --git a/core/src/main/java/hudson/Proc.java b/core/src/main/java/hudson/Proc.java index e1d0766b80..8f3d0f8170 100644 --- a/core/src/main/java/hudson/Proc.java +++ b/core/src/main/java/hudson/Proc.java @@ -345,16 +345,7 @@ public abstract class Proc { // it could be either because another thread is blocking on read, or // it could be a bug in Windows JVM. Who knows. // so I'm abandoning the idea of closing the stream -// try { -// proc.getInputStream().close(); -// } catch (IOException x) { -// LOGGER.log(Level.FINE,"stdin termination failed",x); -// } -// try { -// proc.getErrorStream().close(); -// } catch (IOException x) { -// LOGGER.log(Level.FINE,"stderr termination failed",x); -// } + out.write(msg.getBytes()); out.write('\n'); } diff --git a/core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java b/core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java index c3499035a7..aa8d781032 100644 --- a/core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java +++ b/core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java @@ -76,27 +76,19 @@ public final class MemoryUsageMonitor extends PeriodicWork { private void update() { long used = 0; long max = 0; -// long cur = 0; for (MemoryPoolMXBean pool : pools) { MemoryUsage usage = pool.getCollectionUsage(); if(usage==null) continue; // not available used += usage.getUsed(); max += usage.getMax(); - -// usage = pool.getUsage(); -// if(usage==null) continue; // not available -// cur += usage.getUsed(); } // B -> KB used /= 1024; max /= 1024; -// cur /= 1024; this.used.update(used); this.max.update(max); -// -// return String.format("%d/%d/%d (%d%%)",used,cur,max,used*100/max); } /** diff --git a/core/src/main/java/hudson/model/BuildTimelineWidget.java b/core/src/main/java/hudson/model/BuildTimelineWidget.java index 717052e5bf..66b5f3c1d9 100644 --- a/core/src/main/java/hudson/model/BuildTimelineWidget.java +++ b/core/src/main/java/hudson/model/BuildTimelineWidget.java @@ -61,16 +61,13 @@ public class BuildTimelineWidget { public TimelineEventList doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) throws IOException { TimelineEventList result = new TimelineEventList(); - for (Run r : builds.byTimestamp(min,max)) { + for (Run r : builds.byTimestamp(min,max)) { Event e = new Event(); e.start = new Date(r.getStartTimeInMillis()); e.end = new Date(r.getStartTimeInMillis()+r.getDuration()); // due to SimileAjax.HTML.deEntify (in simile-ajax-bundle.js), "<" are transformed back to "<", but not the "<"; // to protect against XSS e.title = Util.escape(r.getFullDisplayName()).replace("<", "<"); - // what to put in the description? - // e.description = "Longish description of event "+r.getFullDisplayName(); - // e.durationEvent = true; e.link = req.getContextPath()+'/'+r.getUrl(); BallColor c = r.getIconColor(); e.color = String.format("#%06X",c.getBaseColor().darker().getRGB()&0xFFFFFF); diff --git a/core/src/main/java/hudson/model/Fingerprint.java b/core/src/main/java/hudson/model/Fingerprint.java index e31483e070..357232edf2 100644 --- a/core/src/main/java/hudson/model/Fingerprint.java +++ b/core/src/main/java/hudson/model/Fingerprint.java @@ -374,25 +374,6 @@ public class Fingerprint implements ModelObject, Saveable { }; } -// /** -// * List up builds. -// */ -// public ,R extends Run> Iterable listBuilds(final J job) { -// return new Iterable() { -// public Iterator iterator() { -// return new Iterators.FilterIterator(new AdaptedIterator(listNumbers().iterator()) { -// protected R adapt(Integer n) { -// return job.getBuildByNumber(n); -// } -// }) { -// protected boolean filter(R r) { -// return r!=null; -// } -// }; -// } -// }; -// } - /** * List all numbers in this range set in the descending order. */ diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index 4c038af5cd..04efbb5f7d 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -1499,8 +1499,6 @@ public abstract class Job, RunT extends Run implements super(self()); } - // this will never work because Descriptor and Describable are the same thing. -// protected PageDecorator() { -// } @Override public final Descriptor getDescriptor() { diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index 8a1f743402..58c842dd8f 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -1331,28 +1331,6 @@ public abstract class Run ,RunT extends Run names = new HashSet(); -// for (String[] token : tokens) { -// if(!names.add(combineLast(token,n))) -// continue OUTER; // collision. Increase n and try again -// } -// -// // this n successfully disambiguates -// for (int i = 0; i < tokens.length; i++) { -// String[] token = tokens[i]; -// get(i).displayPath = combineLast(token,n); -// } -// return; -// } - -// // it's impossible to get here, as that means -// // we have the same artifacts archived twice, but be defensive -// for (Artifact a : this) -// a.displayPath = a.relativePath; } /** diff --git a/core/src/main/java/hudson/model/Slave.java b/core/src/main/java/hudson/model/Slave.java index 17079a9f2c..7818fa7af3 100644 --- a/core/src/main/java/hudson/model/Slave.java +++ b/core/src/main/java/hudson/model/Slave.java @@ -206,9 +206,6 @@ public abstract class Slave extends Node implements Serializable { if (name.equals("")) throw new FormException(Messages.Slave_InvalidConfig_NoName(), null); -// if (remoteFS.equals("")) -// throw new FormException(Messages.Slave_InvalidConfig_NoRemoteDir(name), null); - if (this.numExecutors<=0) throw new FormException(Messages.Slave_InvalidConfig_Executors(name), null); } diff --git a/core/src/main/java/hudson/model/TreeView.java b/core/src/main/java/hudson/model/TreeView.java index 00191fc97a..8c9543f15a 100644 --- a/core/src/main/java/hudson/model/TreeView.java +++ b/core/src/main/java/hudson/model/TreeView.java @@ -97,19 +97,11 @@ public class TreeView extends View implements ViewGroup { @Override public synchronized List getItems() { return Jenkins.get().getItems(); -// List items = new ArrayList(jobNames.size()); -// for (String name : jobNames) { -// TopLevelItem item = Hudson.getInstance().getItem(name); -// if(item!=null) -// items.add(item); -// } -// return items; } @Override public boolean contains(TopLevelItem item) { return true; -// return jobNames.contains(item.getName()); } @Override diff --git a/core/src/main/java/hudson/model/queue/MappingWorksheet.java b/core/src/main/java/hudson/model/queue/MappingWorksheet.java index cced8c0ac8..d60809b2d0 100644 --- a/core/src/main/java/hudson/model/queue/MappingWorksheet.java +++ b/core/src/main/java/hudson/model/queue/MappingWorksheet.java @@ -173,12 +173,6 @@ public class MappingWorksheet { public class WorkChunk extends ReadOnlyList { public final int index; - // the main should be always at position 0 -// /** -// * This chunk includes {@linkplain WorkUnit#isMainWork() the main work unit}. -// */ -// public final boolean isMain; - /** * If this task needs to be run on a node with a particular label, * return that {@link Label}. Otherwise null, indicating diff --git a/core/src/main/java/hudson/node_monitors/AbstractNodeMonitorDescriptor.java b/core/src/main/java/hudson/node_monitors/AbstractNodeMonitorDescriptor.java index 3861bfca21..e773688839 100644 --- a/core/src/main/java/hudson/node_monitors/AbstractNodeMonitorDescriptor.java +++ b/core/src/main/java/hudson/node_monitors/AbstractNodeMonitorDescriptor.java @@ -194,8 +194,6 @@ public abstract class AbstractNodeMonitorDescriptor extends Descriptor0) buf.append(','); -// buf.append(l); -// } -// return buf.toString(); int fc = failureCount(); if(fc>0) return Messages.ResponseTimeMonitor_TimeOut(fc); diff --git a/core/src/main/java/hudson/security/BasicAuthenticationFilter.java b/core/src/main/java/hudson/security/BasicAuthenticationFilter.java index 836ddd5f1d..d481260c3a 100644 --- a/core/src/main/java/hudson/security/BasicAuthenticationFilter.java +++ b/core/src/main/java/hudson/security/BasicAuthenticationFilter.java @@ -178,20 +178,6 @@ public class BasicAuthenticationFilter implements Filter { rsp.setHeader("Location",path); } - //public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - // HttpServletRequest req = (HttpServletRequest) request; - // String authorization = req.getHeader("Authorization"); - // - // String path = req.getServletPath(); - // if(authorization==null || req.getUserPrincipal()!=null || path.startsWith("/secured/")) { - // chain.doFilter(request,response); - // } else { - // if(req.getQueryString()!=null) - // path += req.getQueryString(); - // ((HttpServletResponse)response).sendRedirect(req.getContextPath()+"/secured"+path); - // } - //} - @Override public void destroy() { } diff --git a/core/src/main/java/hudson/util/ChunkedInputStream.java b/core/src/main/java/hudson/util/ChunkedInputStream.java index 491e8885fa..b934fd7af9 100644 --- a/core/src/main/java/hudson/util/ChunkedInputStream.java +++ b/core/src/main/java/hudson/util/ChunkedInputStream.java @@ -284,25 +284,6 @@ public class ChunkedInputStream extends InputStream { private void parseTrailerHeaders() throws IOException { // I feel lazy. No trailing header support readCRLF(); - -// Header[] footers = null; -// try { -// String charset = "US-ASCII"; -// if (this.method != null) { -// charset = this.method.getParams().getHttpElementCharset(); -// } -// footers = HttpParser.parseHeaders(in, charset); -// } catch(HttpException e) { -// LOG.error("Error parsing trailer headers", e); -// IOException ioe = new IOException(e.getMessage()); -// ExceptionUtil.initCause(ioe, e); -// throw ioe; -// } -// if (this.method != null) { -// for (int i = 0; i < footers.length; i++) { -// this.method.addResponseFooter(footers[i]); -// } -// } } /** diff --git a/core/src/main/java/hudson/util/ProcessTree.java b/core/src/main/java/hudson/util/ProcessTree.java index 8bcaf49a5f..29435b931f 100644 --- a/core/src/main/java/hudson/util/ProcessTree.java +++ b/core/src/main/java/hudson/util/ProcessTree.java @@ -1691,9 +1691,6 @@ public abstract class ProcessTree implements Iterable, IProcessTree, for( int base=0; base, IProcessTree, return new Remote(this, getChannelForSerialization()); } -// public static void main(String[] args) { -// // dump everything -// LOGGER.setLevel(Level.ALL); -// ConsoleHandler h = new ConsoleHandler(); -// h.setLevel(Level.ALL); -// LOGGER.addHandler(h); -// -// Solaris killer = (Solaris)get(); -// Solaris.SolarisSystem s = killer.createSystem(); -// Solaris.SolarisProcess p = s.get(Integer.parseInt(args[0])); -// System.out.println(p.getEnvVars()); -// -// if(args.length==2) -// p.kill(); -// } - /* On MacOS X, there's no procfs instead you'd do it with the sysctl diff --git a/core/src/main/java/jenkins/security/LastGrantedAuthoritiesProperty.java b/core/src/main/java/jenkins/security/LastGrantedAuthoritiesProperty.java index da348b768f..cfe795746a 100644 --- a/core/src/main/java/jenkins/security/LastGrantedAuthoritiesProperty.java +++ b/core/src/main/java/jenkins/security/LastGrantedAuthoritiesProperty.java @@ -136,28 +136,6 @@ public class LastGrantedAuthoritiesProperty extends UserProperty { // while this initially seemed like a good idea to avoid allowing wrong impersonation for too long, // doing this means a malicious user can break the impersonation capability // just by failing to login. See ApiTokenFilter that does the following, which seems better: - /* - try { - Jenkins.get().getSecurityRealm().loadUserByUsername(username); - } catch (UserMayOrMayNotExistException x) { - // OK, give them the benefit of the doubt. - } catch (UsernameNotFoundException x) { - // Not/no longer a user; deny the API token. (But do not leak the information that this happened.) - chain.doFilter(request, response); - return; - } catch (DataAccessException x) { - throw new ServletException(x); - } - */ - -// try { -// User u = User.getById(username,false); -// LastGrantedAuthoritiesProperty o = u.getProperty(LastGrantedAuthoritiesProperty.class); -// if (o!=null) -// o.invalidate(); -// } catch (IOException e) { -// LOGGER.log(Level.WARNING, "Failed to record granted authorities",e); -// } } } diff --git a/core/src/test/java/jenkins/RemotingJarSignatureTest.java b/core/src/test/java/jenkins/RemotingJarSignatureTest.java index 7bf5ac7264..f054d6b170 100644 --- a/core/src/test/java/jenkins/RemotingJarSignatureTest.java +++ b/core/src/test/java/jenkins/RemotingJarSignatureTest.java @@ -1,5 +1,6 @@ package jenkins; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import hudson.remoting.Channel; @@ -23,8 +24,6 @@ public class RemotingJarSignatureTest { @Test public void testSignature() throws Exception { File jar = Which.jarFile(Channel.class); -// File jar = new File("/home/kohsuke/.m2/repository/org/jenkins-ci/main/remoting/1.421/remoting-1.421.jar"); -// File jar = new File("/home/kohsuke/.m2/repository/org/jenkins-ci/main/remoting/2.0/remoting-2.0.jar"); System.out.println("Verifying "+jar); JarFile myJar = new JarFile(jar,true); @@ -43,9 +42,7 @@ public class RemotingJarSignatureTest { // make sure bits are signed IOUtils.copy(myJar.getInputStream(entry), NullOutputStream.NULL_OUTPUT_STREAM); - if (entry.getCodeSigners()==null) { - fail("No signature for " + name); - } + assertNotNull("No signature for " + name, entry.getCodeSigners()); } } }