idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
17,000 | private Class findClassInComponents ( String name ) throws ClassNotFoundException { String classFilename = getClassFilename ( name ) ; Enumeration e = pathComponents . elements ( ) ; while ( e . hasMoreElements ( ) ) { File pathComponent = ( File ) e . nextElement ( ) ; try ( final InputStream stream = getResourceStream ( pathComponent , classFilename ) ) { if ( stream != null ) { log ( "Loaded from " + pathComponent + " " + classFilename , Project . MSG_DEBUG ) ; return getClassFromStream ( stream , name , pathComponent ) ; } } catch ( SecurityException se ) { throw se ; } catch ( IOException ioe ) { log ( "Exception reading component " + pathComponent + " (reason: " + ioe . getMessage ( ) + ")" , Project . MSG_VERBOSE ) ; } } throw new ClassNotFoundException ( name ) ; } | Finds a class on the given classpath . |
17,001 | public synchronized void cleanup ( ) { for ( Enumeration e = jarFiles . elements ( ) ; e . hasMoreElements ( ) ; ) { JarFile jarFile = ( JarFile ) e . nextElement ( ) ; try { jarFile . close ( ) ; } catch ( IOException ioe ) { } } jarFiles = new Hashtable ( ) ; if ( project != null ) { project . removeBuildListener ( this ) ; } project = null ; } | Cleans up any resources held by this classloader . Any open archive files are closed . |
17,002 | public void addJavaLibraries ( ) { Vector packages = JavaEnvUtils . getJrePackages ( ) ; Enumeration e = packages . elements ( ) ; while ( e . hasMoreElements ( ) ) { String packageName = ( String ) e . nextElement ( ) ; addSystemPackageRoot ( packageName ) ; } } | add any libraries that come with different java versions here |
17,003 | public synchronized void doDoDelete ( StaplerResponse rsp ) throws IOException , ServletException { getConfigFile ( ) . delete ( ) ; getParent ( ) . logRecorders . remove ( name ) ; for ( Target t : targets ) t . disable ( ) ; for ( LogRecorder log : getParent ( ) . logRecorders . values ( ) ) for ( Target t : log . targets ) t . enable ( ) ; rsp . sendRedirect2 ( ".." ) ; } | Deletes this recorder then go back to the parent . |
17,004 | public Map < Computer , List < LogRecord > > getSlaveLogRecords ( ) { Map < Computer , List < LogRecord > > result = new TreeMap < Computer , List < LogRecord > > ( new Comparator < Computer > ( ) { final Collator COLL = Collator . getInstance ( ) ; public int compare ( Computer c1 , Computer c2 ) { return COLL . compare ( c1 . getDisplayName ( ) , c2 . getDisplayName ( ) ) ; } } ) ; for ( Computer c : Jenkins . getInstance ( ) . getComputers ( ) ) { if ( c . getName ( ) . length ( ) == 0 ) { continue ; } List < LogRecord > recs = new ArrayList < LogRecord > ( ) ; try { for ( LogRecord rec : c . getLogRecords ( ) ) { for ( Target t : targets ) { if ( t . includes ( rec ) ) { recs . add ( rec ) ; break ; } } } } catch ( IOException x ) { continue ; } catch ( InterruptedException x ) { continue ; } if ( ! recs . isEmpty ( ) ) { result . put ( c , recs ) ; } } return result ; } | Gets a view of log records per agent matching this recorder . |
17,005 | public synchronized static Lifecycle get ( ) { if ( INSTANCE == null ) { Lifecycle instance ; String p = SystemProperties . getString ( "hudson.lifecycle" ) ; if ( p != null ) { try { ClassLoader cl = Jenkins . getInstance ( ) . getPluginManager ( ) . uberClassLoader ; instance = ( Lifecycle ) cl . loadClass ( p ) . newInstance ( ) ; } catch ( InstantiationException e ) { InstantiationError x = new InstantiationError ( e . getMessage ( ) ) ; x . initCause ( e ) ; throw x ; } catch ( IllegalAccessException e ) { IllegalAccessError x = new IllegalAccessError ( e . getMessage ( ) ) ; x . initCause ( e ) ; throw x ; } catch ( ClassNotFoundException e ) { NoClassDefFoundError x = new NoClassDefFoundError ( e . getMessage ( ) ) ; x . initCause ( e ) ; throw x ; } } else { if ( Functions . isWindows ( ) ) { instance = new Lifecycle ( ) { public void verifyRestartable ( ) throws RestartNotSupportedException { throw new RestartNotSupportedException ( "Default Windows lifecycle does not support restart." ) ; } } ; } else if ( System . getenv ( "SMF_FMRI" ) != null && System . getenv ( "SMF_RESTARTER" ) != null ) { instance = new SolarisSMFLifecycle ( ) ; } else { try { instance = new UnixLifecycle ( ) ; } catch ( final IOException e ) { LOGGER . log ( Level . WARNING , "Failed to install embedded lifecycle implementation" , e ) ; instance = new Lifecycle ( ) { public void verifyRestartable ( ) throws RestartNotSupportedException { throw new RestartNotSupportedException ( "Failed to install embedded lifecycle implementation, so cannot restart: " + e , e ) ; } } ; } } } assert instance != null ; INSTANCE = instance ; } return INSTANCE ; } | Gets the singleton instance . |
17,006 | public void rewriteHudsonWar ( File by ) throws IOException { File dest = getHudsonWar ( ) ; if ( dest == null ) throw new IOException ( "jenkins.war location is not known." ) ; File bak = new File ( dest . getPath ( ) + ".bak" ) ; if ( ! by . equals ( bak ) ) FileUtils . copyFile ( dest , bak ) ; FileUtils . copyFile ( by , dest ) ; if ( by . equals ( bak ) && bak . exists ( ) ) bak . delete ( ) ; } | Replaces jenkins . war by the given file . |
17,007 | public synchronized void load2 ( ) throws IOException { COL result = create ( ) ; if ( exists ( ) ) { try ( LinesStream stream = linesStream ( ) ) { for ( String line : stream ) { if ( line . startsWith ( "#" ) ) continue ; T r = parse ( line ) ; if ( r != null ) result . add ( r ) ; } } } parsed = readOnly ( result ) ; } | Loads the configuration from the configuration file . |
17,008 | public Object read ( ) throws IOException { if ( LOGGER . isLoggable ( Level . FINE ) ) { LOGGER . fine ( "Reading " + file ) ; } try ( InputStream in = new BufferedInputStream ( Files . newInputStream ( file . toPath ( ) ) ) ) { return xs . fromXML ( in ) ; } catch ( RuntimeException | Error e ) { throw new IOException ( "Unable to read " + file , e ) ; } } | Loads the contents of this file into a new object . |
17,009 | public String asString ( ) throws IOException { StringWriter w = new StringWriter ( ) ; writeRawTo ( w ) ; return w . toString ( ) ; } | Returns the XML file read as a string . |
17,010 | public String sniffEncoding ( ) throws IOException { class Eureka extends SAXException { final String encoding ; public Eureka ( String encoding ) { this . encoding = encoding ; } } try ( InputStream in = Files . newInputStream ( file . toPath ( ) ) ) { InputSource input = new InputSource ( file . toURI ( ) . toASCIIString ( ) ) ; input . setByteStream ( in ) ; JAXP . newSAXParser ( ) . parse ( input , new DefaultHandler ( ) { private Locator loc ; public void setDocumentLocator ( Locator locator ) { this . loc = locator ; } public void startDocument ( ) throws SAXException { attempt ( ) ; } public void startElement ( String uri , String localName , String qName , Attributes attributes ) throws SAXException { attempt ( ) ; throw new Eureka ( null ) ; } private void attempt ( ) throws Eureka { if ( loc == null ) return ; if ( loc instanceof Locator2 ) { Locator2 loc2 = ( Locator2 ) loc ; String e = loc2 . getEncoding ( ) ; if ( e != null ) throw new Eureka ( e ) ; } } } ) ; throw new AssertionError ( ) ; } catch ( Eureka e ) { if ( e . encoding != null ) return e . encoding ; return "UTF-8" ; } catch ( SAXException e ) { throw new IOException ( "Failed to detect encoding of " + file , e ) ; } catch ( InvalidPathException e ) { throw new IOException ( e ) ; } catch ( ParserConfigurationException e ) { throw new AssertionError ( e ) ; } } | Parses the beginning of the file and determines the encoding . |
17,011 | private String findRememberMeCookieValue ( HttpServletRequest request , HttpServletResponse response ) { Cookie [ ] cookies = request . getCookies ( ) ; if ( ( cookies == null ) || ( cookies . length == 0 ) ) { return null ; } for ( Cookie cookie : cookies ) { if ( ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY . equals ( cookie . getName ( ) ) ) { return cookie . getValue ( ) ; } } return null ; } | Patched version of the super . autoLogin with a time - independent equality check for the token validation |
17,012 | private Authentication retrieveAuthFromCookie ( HttpServletRequest request , HttpServletResponse response , String cookieValueBase64 ) { String cookieValue = decodeCookieBase64 ( cookieValueBase64 ) ; if ( cookieValue == null ) { String reason = "Cookie token was not Base64 encoded; value was '" + cookieValueBase64 + "'" ; cancelCookie ( request , response , reason ) ; return null ; } if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Remember-me cookie detected" ) ; } String [ ] cookieTokens = StringUtils . delimitedListToStringArray ( cookieValue , ":" ) ; if ( cookieTokens . length != 3 ) { cancelCookie ( request , response , "Cookie token did not contain 3 tokens separated by [:]" ) ; return null ; } long tokenExpiryTime ; try { tokenExpiryTime = Long . parseLong ( cookieTokens [ 1 ] ) ; } catch ( NumberFormatException nfe ) { cancelCookie ( request , response , "Cookie token[1] did not contain a valid number" ) ; return null ; } if ( isTokenExpired ( tokenExpiryTime ) ) { cancelCookie ( request , response , "Cookie token[1] has expired" ) ; return null ; } UserDetails userDetails = loadUserDetails ( request , response , cookieTokens ) ; if ( userDetails == null ) { cancelCookie ( request , response , "Cookie token[0] contained a username without user associated" ) ; return null ; } if ( ! isValidUserDetails ( request , response , userDetails , cookieTokens ) ) { return null ; } String receivedTokenSignature = cookieTokens [ 2 ] ; String expectedTokenSignature = makeTokenSignature ( tokenExpiryTime , userDetails ) ; boolean tokenValid = MessageDigest . isEqual ( expectedTokenSignature . getBytes ( StandardCharsets . US_ASCII ) , receivedTokenSignature . getBytes ( StandardCharsets . US_ASCII ) ) ; if ( ! tokenValid ) { cancelCookie ( request , response , "Cookie token[2] contained invalid signature" ) ; return null ; } if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Remember-me cookie accepted" ) ; } RememberMeAuthenticationToken auth = new RememberMeAuthenticationToken ( this . getKey ( ) , userDetails , userDetails . getAuthorities ( ) ) ; auth . setDetails ( authenticationDetailsSource . buildDetails ( request ) ) ; return auth ; } | and reducing drastically the information provided in the log to avoid potential disclosure |
17,013 | private void secureCookie ( Cookie cookie , HttpServletRequest request ) { if ( SET_HTTP_ONLY != null ) { try { SET_HTTP_ONLY . invoke ( cookie , true ) ; } catch ( IllegalAccessException | InvocationTargetException e ) { } } cookie . setSecure ( request . isSecure ( ) ) ; } | Force always the http - only flag and depending on the request put also the secure flag . |
17,014 | protected boolean isTokenExpired ( long tokenExpiryTimeMs ) { long nowMs = System . currentTimeMillis ( ) ; long maxExpirationMs = TimeUnit . SECONDS . toMillis ( tokenValiditySeconds ) + nowMs ; if ( ! SKIP_TOO_FAR_EXPIRATION_DATE_CHECK && tokenExpiryTimeMs > maxExpirationMs ) { long diffMs = tokenExpiryTimeMs - maxExpirationMs ; LOGGER . log ( Level . WARNING , "Attempt to use a cookie with an expiration duration larger than the one configured (delta of: {0} ms)" , diffMs ) ; return true ; } if ( tokenExpiryTimeMs < nowMs ) { return true ; } return false ; } | In addition to the expiration requested by the super class we also check the expiration is not too far in the future . Especially to detect maliciously crafted cookie . |
17,015 | public final List < OSProcess > getChildren ( ) { List < OSProcess > r = new ArrayList < OSProcess > ( ) ; for ( OSProcess p : ProcessTree . this ) if ( p . getParent ( ) == this ) r . add ( p ) ; return r ; } | Immediate child processes . |
17,016 | public < T > T act ( ProcessCallable < T > callable ) throws IOException , InterruptedException { return callable . invoke ( this , FilePath . localChannel ) ; } | Executes a chunk of code at the same machine where this process resides . |
17,017 | public void kill ( ) throws InterruptedException { long deadline = System . nanoTime ( ) + TimeUnit . SECONDS . toNanos ( softKillWaitSeconds ) ; kill ( deadline ) ; } | Tries to kill this process . |
17,018 | public static String hashify ( String spec ) { if ( spec . contains ( "H" ) ) { return null ; } else if ( spec . startsWith ( "*/" ) ) { return "H" + spec . substring ( 1 ) ; } else if ( spec . matches ( "\\d+ .+" ) ) { return "H " + spec . substring ( spec . indexOf ( ' ' ) + 1 ) ; } else { Matcher m = Pattern . compile ( "0(,(\\d+)(,\\d+)*)( .+)" ) . matcher ( spec ) ; if ( m . matches ( ) ) { int period = Integer . parseInt ( m . group ( 2 ) ) ; if ( period > 0 ) { StringBuilder b = new StringBuilder ( ) ; for ( int i = period ; i < 60 ; i += period ) { b . append ( ',' ) . append ( i ) ; } if ( b . toString ( ) . equals ( m . group ( 1 ) ) ) { return "H/" + period + m . group ( 4 ) ; } } } return null ; } } | Checks a prospective crontab specification to see if it could benefit from balanced hashes . |
17,019 | public String toHtml ( MemoryUsage usage ) { if ( usage . availableSwapSpace == - 1 ) return "N/A" ; String humanReadableSpace = Functions . humanReadableByteSize ( usage . availableSwapSpace ) ; long free = usage . availableSwapSpace ; free /= 1024L ; free /= 1024L ; if ( free > 256 || usage . totalSwapSpace < usage . availableSwapSpace * 5 ) return humanReadableSpace ; return Util . wrapToErrorSpan ( humanReadableSpace ) ; } | Returns the HTML representation of the space . |
17,020 | public void update ( float newData ) { float data = history [ 0 ] * decay + newData * ( 1 - decay ) ; float [ ] r = new float [ Math . min ( history . length + 1 , historySize ) ] ; System . arraycopy ( history , 0 , r , 1 , Math . min ( history . length , r . length - 1 ) ) ; r [ 0 ] = data ; history = r ; } | Pushes a new data point . |
17,021 | public void annotate ( Run < ? , ? > build , Entry change , MarkupText text ) { if ( build instanceof AbstractBuild && Util . isOverridden ( ChangeLogAnnotator . class , getClass ( ) , "annotate" , AbstractBuild . class , Entry . class , MarkupText . class ) ) { annotate ( ( AbstractBuild ) build , change , text ) ; } else { Logger . getLogger ( ChangeLogAnnotator . class . getName ( ) ) . log ( Level . WARNING , "You must override the newer overload of annotate from {0}" , getClass ( ) . getName ( ) ) ; } } | Called by Hudson to allow markups to be added to the changelog text . |
17,022 | public static ResourceList union ( Collection < ResourceList > lists ) { switch ( lists . size ( ) ) { case 0 : return EMPTY ; case 1 : return lists . iterator ( ) . next ( ) ; default : ResourceList r = new ResourceList ( ) ; for ( ResourceList l : lists ) { r . all . addAll ( l . all ) ; for ( Entry < Resource , Integer > e : l . write . entrySet ( ) ) r . write . put ( e . getKey ( ) , unbox ( r . write . get ( e . getKey ( ) ) ) + e . getValue ( ) ) ; } return r ; } } | Creates union of all resources . |
17,023 | public ResourceList w ( Resource r ) { all . add ( r ) ; write . put ( r , unbox ( write . get ( r ) ) + 1 ) ; return this ; } | Adds a resource for write access . |
17,024 | public Resource getConflict ( ResourceList that ) { Resource r = _getConflict ( this , that ) ; if ( r != null ) return r ; return _getConflict ( that , this ) ; } | Returns the resource in this list that s colliding with the given resource list . |
17,025 | public R get ( ) { Holder < R > h = holder ; return h != null ? h . get ( ) : null ; } | Gets the build if still in memory . |
17,026 | @ SuppressWarnings ( "unchecked" ) public static < T > ConsoleAnnotator < T > cast ( ConsoleAnnotator < ? super T > a ) { return ( ConsoleAnnotator ) a ; } | Cast operation that restricts T . |
17,027 | @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static < T > List < ConsoleAnnotator < T > > _for ( T context ) { List < ConsoleAnnotator < T > > r = new ArrayList < > ( ) ; for ( ConsoleAnnotatorFactory f : ConsoleAnnotatorFactory . all ( ) ) { if ( f . type ( ) . isInstance ( context ) ) { ConsoleAnnotator ca = f . newInstance ( context ) ; if ( ca != null ) r . add ( ca ) ; } } return r ; } | List all the console annotators that can work for the specified context type . |
17,028 | public String generateFragment ( ) { if ( ! DownloadSettings . usePostBack ( ) ) { return "" ; } if ( neverUpdate ) return "" ; if ( doesNotSupportPostMessage ( ) ) return "" ; StringBuilder buf = new StringBuilder ( ) ; if ( Jenkins . getInstance ( ) . hasPermission ( Jenkins . READ ) ) { long now = System . currentTimeMillis ( ) ; for ( Downloadable d : Downloadable . all ( ) ) { if ( d . getDue ( ) < now && d . lastAttempt + TimeUnit . SECONDS . toMillis ( 10 ) < now ) { buf . append ( "<script>" ) . append ( "Behaviour.addLoadEvent(function() {" ) . append ( " downloadService.download(" ) . append ( QuotedStringTokenizer . quote ( d . getId ( ) ) ) . append ( ',' ) . append ( QuotedStringTokenizer . quote ( mapHttps ( d . getUrl ( ) ) ) ) . append ( ',' ) . append ( "{version:" + QuotedStringTokenizer . quote ( Jenkins . VERSION ) + '}' ) . append ( ',' ) . append ( QuotedStringTokenizer . quote ( Stapler . getCurrentRequest ( ) . getContextPath ( ) + '/' + getUrl ( ) + "/byId/" + d . getId ( ) + "/postBack" ) ) . append ( ',' ) . append ( "null);" ) . append ( "});" ) . append ( "</script>" ) ; d . lastAttempt = now ; } } } return buf . toString ( ) ; } | Builds up an HTML fragment that starts all the download jobs . |
17,029 | public Run < ? , ? > resolve ( Job < ? , ? > job ) { File f = getPermalinkFile ( job ) ; Run < ? , ? > b = null ; try { String target = readSymlink ( f ) ; if ( target != null ) { int n = Integer . parseInt ( Util . getFileName ( target ) ) ; if ( n == RESOLVES_TO_NONE ) return null ; b = job . getBuildByNumber ( n ) ; if ( b != null && apply ( b ) ) return b ; if ( b == null ) b = job . getNearestOldBuild ( n ) ; } } catch ( InterruptedException e ) { LOGGER . log ( Level . WARNING , "Failed to read permalink cache:" + f , e ) ; } catch ( NumberFormatException e ) { LOGGER . log ( Level . WARNING , "Failed to parse the build number in the permalink cache:" + f , e ) ; } catch ( IOException e ) { } if ( b == null ) { b = job . getLastBuild ( ) ; } b = find ( b ) ; updateCache ( job , b ) ; return b ; } | Resolves the permalink by using the cache if possible . |
17,030 | private Run < ? , ? > find ( Run < ? , ? > b ) { for ( ; b != null && ! apply ( b ) ; b = b . getPreviousBuild ( ) ) ; return b ; } | Start from the build b and locate the build that matches the criteria going back in time |
17,031 | private static boolean exists ( File link ) { File [ ] kids = link . getParentFile ( ) . listFiles ( ) ; return kids != null && Arrays . asList ( kids ) . contains ( link ) ; } | File . exists returns false for a link with a missing target so for Java 6 compatibility we have to use this circuitous method to see if it was created . |
17,032 | private String loadScript ( ) throws CmdLineException , IOException , InterruptedException { if ( script == null ) throw new CmdLineException ( null , "No script is specified" ) ; if ( script . equals ( "=" ) ) return IOUtils . toString ( stdin ) ; checkChannel ( ) ; return null ; } | Loads the script from the argument . |
17,033 | public int compare ( BuildableItem lhs , BuildableItem rhs ) { return compare ( lhs . buildableStartMilliseconds , rhs . buildableStartMilliseconds ) ; } | Override this method to provide the ordering of the sort . |
17,034 | public void replace ( T item ) throws IOException { removeAll ( ( Class ) item . getClass ( ) ) ; data . add ( item ) ; onModified ( ) ; } | Removes all instances of the same type then add the new one . |
17,035 | public T getDynamic ( String id ) { for ( T t : data ) if ( t . getDescriptor ( ) . getId ( ) . equals ( id ) ) return t ; try { return data . get ( Integer . parseInt ( id ) ) ; } catch ( NumberFormatException e ) { } return null ; } | Binds items in the collection to URL . |
17,036 | public void configure ( StaplerRequest req , JSONObject formData ) throws IOException , ServletException , FormException { configure ( formData ) ; } | Handles the submission for the system configuration . |
17,037 | public void save ( ) throws IOException { if ( BulkChange . contains ( this ) ) return ; XmlFile config = getConfigXml ( ) ; config . write ( this ) ; SaveableListener . fireOnChange ( this , config ) ; } | Saves serializable fields of this instance to the persisted storage . |
17,038 | public void terminate ( ) throws InterruptedException , IOException { final Computer computer = toComputer ( ) ; if ( computer != null ) { computer . recordTermination ( ) ; } try { _terminate ( new StreamTaskListener ( System . out , Charset . defaultCharset ( ) ) ) ; } finally { try { Jenkins . get ( ) . removeNode ( this ) ; } catch ( IOException e ) { LOGGER . log ( Level . WARNING , "Failed to remove " + name , e ) ; } } } | Releases and removes this agent . |
17,039 | public static String quote ( String s ) { if ( s == null ) return null ; if ( s . length ( ) == 0 ) return "\"\"" ; StringBuffer b = new StringBuffer ( s . length ( ) + 8 ) ; quote ( b , s ) ; return b . toString ( ) ; } | Quote a string . The string is quoted only if quoting is required due to embedded delimiters quote characters or the empty string . |
17,040 | public synchronized void reset ( TreeMap < Integer , R > builds ) { Index index = new Index ( ) ; for ( R r : builds . values ( ) ) { BuildReference < R > ref = createReference ( r ) ; index . byNumber . put ( getNumberOf ( r ) , ref ) ; } this . index = index ; } | Replaces all the current loaded Rs with the given ones . |
17,041 | public void disable ( boolean value ) throws IOException { AbstractCIBase jenkins = Jenkins . get ( ) ; Set < String > set = jenkins . getDisabledAdministrativeMonitors ( ) ; if ( value ) set . add ( id ) ; else set . remove ( id ) ; jenkins . save ( ) ; } | Mark this monitor as disabled to prevent this from showing up in the UI . |
17,042 | public void doDisable ( StaplerRequest req , StaplerResponse rsp ) throws IOException { disable ( true ) ; rsp . sendRedirect2 ( req . getContextPath ( ) + "/manage" ) ; } | URL binding to disable this monitor . |
17,043 | public ArgumentListBuilder add ( String a , boolean mask ) { if ( a != null ) { if ( mask ) { this . mask . set ( args . size ( ) ) ; } args . add ( a ) ; } return this ; } | Optionally hide this part of the command line from being printed to the log . |
17,044 | public ArgumentListBuilder addTokenized ( String s ) { if ( s == null ) return this ; add ( Util . tokenize ( s ) ) ; return this ; } | Decomposes the given token into multiple arguments by splitting via whitespace . |
17,045 | public ArgumentListBuilder addKeyValuePairs ( String prefix , Map < String , String > props ) { for ( Entry < String , String > e : props . entrySet ( ) ) addKeyValuePair ( prefix , e . getKey ( ) , e . getValue ( ) , false ) ; return this ; } | Adds key value pairs as - Dkey = value - Dkey = value ... |
17,046 | public ArgumentListBuilder addKeyValuePairs ( String prefix , Map < String , String > props , Set < String > propsToMask ) { for ( Entry < String , String > e : props . entrySet ( ) ) { addKeyValuePair ( prefix , e . getKey ( ) , e . getValue ( ) , ( propsToMask != null ) && propsToMask . contains ( e . getKey ( ) ) ) ; } return this ; } | Adds key value pairs as - Dkey = value - Dkey = value ... with masking . |
17,047 | private static VariableResolver < String > propertiesGeneratingResolver ( final VariableResolver < String > original ) { return new VariableResolver < String > ( ) { public String resolve ( String name ) { final String value = original . resolve ( name ) ; if ( value == null ) return null ; return value . replaceAll ( "\\\\" , "\\\\\\\\" ) ; } } ; } | Creates a resolver generating values to be safely placed in properties string . |
17,048 | public final VirtualChannel getChannel ( ) { Computer c = toComputer ( ) ; return c == null ? null : c . getChannel ( ) ; } | Gets the current channel if the node is connected and online or null . |
17,049 | public TagCloud < LabelAtom > getLabelCloud ( ) { return new TagCloud < LabelAtom > ( getAssignedLabels ( ) , new WeightFunction < LabelAtom > ( ) { public float weight ( LabelAtom item ) { return item . getTiedJobCount ( ) ; } } ) ; } | Return the possibly empty tag cloud for the labels of this node . |
17,050 | private HashSet < LabelAtom > getDynamicLabels ( ) { HashSet < LabelAtom > result = new HashSet < LabelAtom > ( ) ; for ( LabelFinder labeler : LabelFinder . all ( ) ) { for ( Label label : labeler . findLabels ( this ) ) if ( label instanceof LabelAtom ) result . add ( ( LabelAtom ) label ) ; } return result ; } | Return all the labels assigned dynamically to this node . This calls all the LabelFinder implementations with the node converts the results into Labels . |
17,051 | public < T extends NodeProperty > T getNodeProperty ( Class < T > clazz ) { for ( NodeProperty p : getNodeProperties ( ) ) { if ( clazz . isInstance ( p ) ) { return clazz . cast ( p ) ; } } return null ; } | Gets the specified property or null if the property is not configured for this Node . |
17,052 | public NodeProperty getNodeProperty ( String className ) { for ( NodeProperty p : getNodeProperties ( ) ) { if ( p . getClass ( ) . getName ( ) . equals ( className ) ) { return p ; } } return null ; } | Gets the property from the given classname or null if the property is not configured for this Node . |
17,053 | public ClockDifference getClockDifference ( ) throws IOException , InterruptedException { VirtualChannel channel = getChannel ( ) ; if ( channel == null ) throw new IOException ( getNodeName ( ) + " is offline" ) ; return channel . call ( getClockDifferenceCallable ( ) ) ; } | Estimates the clock difference with this agent . |
17,054 | public static List < Pattern > getNoProxyHostPatterns ( String noProxyHost ) { if ( noProxyHost == null ) return Collections . emptyList ( ) ; List < Pattern > r = Lists . newArrayList ( ) ; for ( String s : noProxyHost . split ( "[ \t\n,|]+" ) ) { if ( s . length ( ) == 0 ) continue ; r . add ( Pattern . compile ( s . replace ( "." , "\\." ) . replace ( "*" , ".*" ) ) ) ; } return r ; } | Returns the list of properly formatted no proxy host names . |
17,055 | private void jenkins48775workaround ( Proxy proxy , URL url ) { if ( "https" . equals ( url . getProtocol ( ) ) && ! authCacheSeeded && proxy != Proxy . NO_PROXY ) { HttpURLConnection preAuth = null ; try { preAuth = ( HttpURLConnection ) new URL ( "http" , url . getHost ( ) , - 1 , "/" ) . openConnection ( proxy ) ; preAuth . setRequestMethod ( "HEAD" ) ; preAuth . connect ( ) ; } catch ( IOException e ) { } finally { if ( preAuth != null ) { preAuth . disconnect ( ) ; } } authCacheSeeded = true ; } else if ( "https" . equals ( url . getProtocol ( ) ) ) { authCacheSeeded = authCacheSeeded || proxy != Proxy . NO_PROXY ; } } | If the first URL we try to access with a HTTP proxy is HTTPS then the authentication cache will not have been pre - populated so we try to access at least one HTTP URL before the very first HTTPS url . |
17,056 | public boolean isOffline ( ) { for ( Node n : getNodes ( ) ) { Computer c = n . toComputer ( ) ; if ( c != null && ! c . isOffline ( ) ) return false ; } return true ; } | Returns true if all the nodes of this label is offline . |
17,057 | public String getDescription ( ) { Set < Node > nodes = getNodes ( ) ; if ( nodes . isEmpty ( ) ) { Set < Cloud > clouds = getClouds ( ) ; if ( clouds . isEmpty ( ) ) return Messages . Label_InvalidLabel ( ) ; return Messages . Label_ProvisionedFrom ( toString ( clouds ) ) ; } if ( nodes . size ( ) == 1 ) return nodes . iterator ( ) . next ( ) . getNodeDescription ( ) ; return Messages . Label_GroupOf ( toString ( nodes ) ) ; } | Returns a human readable text that explains this label . |
17,058 | public int getTiedJobCount ( ) { if ( tiedJobsCount != - 1 ) return tiedJobsCount ; SecurityContext context = ACL . impersonate ( ACL . SYSTEM ) ; try { int result = 0 ; for ( TopLevelItem topLevelItem : Jenkins . getInstance ( ) . getItemMap ( ) . values ( ) ) { if ( topLevelItem instanceof AbstractProject ) { final AbstractProject project = ( AbstractProject ) topLevelItem ; if ( matches ( project . getAssignedLabelString ( ) ) ) { result ++ ; } } if ( topLevelItem instanceof ItemGroup ) { Stack < ItemGroup > q = new Stack < > ( ) ; q . push ( ( ItemGroup ) topLevelItem ) ; while ( ! q . isEmpty ( ) ) { ItemGroup < ? > parent = q . pop ( ) ; for ( Item i : parent . getItems ( ) ) { if ( i instanceof AbstractProject ) { final AbstractProject project = ( AbstractProject ) i ; if ( matches ( project . getAssignedLabelString ( ) ) ) { result ++ ; } } if ( i instanceof ItemGroup ) { q . push ( ( ItemGroup ) i ) ; } } } } } return tiedJobsCount = result ; } finally { SecurityContextHolder . setContext ( context ) ; } } | Returns an approximate count of projects that are tied on this node . |
17,059 | public Set < LabelAtom > listAtoms ( ) { Set < LabelAtom > r = new HashSet < > ( ) ; accept ( ATOM_COLLECTOR , r ) ; return r ; } | Lists up all the atoms contained in in this label . |
17,060 | public static Label parseExpression ( String labelExpression ) throws ANTLRException { LabelExpressionLexer lexer = new LabelExpressionLexer ( new StringReader ( labelExpression ) ) ; return new LabelExpressionParser ( lexer ) . expr ( ) ; } | Parses the expression into a label expression tree . |
17,061 | public synchronized void delete ( File dir , String id ) { if ( idToNumber . remove ( id ) != null ) { save ( dir ) ; } } | Delete the record of a build . |
17,062 | public static void main ( String ... args ) throws Exception { if ( args . length != 1 ) { throw new Exception ( "pass one parameter, $JENKINS_HOME" ) ; } File root = new File ( args [ 0 ] ) ; File jobs = new File ( root , "jobs" ) ; if ( ! jobs . isDirectory ( ) ) { throw new FileNotFoundException ( "no such $JENKINS_HOME " + root ) ; } new RunIdMigrator ( ) . unmigrateJobsDir ( jobs ) ; } | Reverses the migration in case you want to revert to the older format . |
17,063 | public FormValidation doPostBack ( StaplerRequest req ) throws IOException , GeneralSecurityException { DownloadSettings . checkPostBackAccess ( ) ; return updateData ( IOUtils . toString ( req . getInputStream ( ) , "UTF-8" ) , true ) ; } | This is the endpoint that receives the update center data file from the browser . |
17,064 | public HttpResponse doInvalidateData ( ) { Jenkins . getInstance ( ) . checkPermission ( Jenkins . ADMINISTER ) ; dataTimestamp = 0 ; data = null ; return HttpResponses . ok ( ) ; } | Invalidates the cached data and force retrieval . |
17,065 | public Data getData ( ) { if ( data == null ) { JSONObject o = getJSONObject ( ) ; if ( o != null ) { data = new Data ( o ) ; } } return data ; } | Loads the update center data if any . |
17,066 | public JSONObject getJSONObject ( ) { TextFile df = getDataFile ( ) ; if ( df . exists ( ) ) { try { return JSONObject . fromObject ( df . read ( ) ) ; } catch ( JSONException | IOException e ) { LOGGER . log ( Level . SEVERE , "Failed to parse " + df , e ) ; df . delete ( ) ; return null ; } } else { return null ; } } | Gets the raw update center JSON data . |
17,067 | public List < Plugin > getAvailables ( ) { List < Plugin > r = new ArrayList < > ( ) ; Data data = getData ( ) ; if ( data == null ) return Collections . emptyList ( ) ; for ( Plugin p : data . plugins . values ( ) ) { if ( p . getInstalled ( ) == null ) r . add ( p ) ; } return r ; } | Returns a list of plugins that should be shown in the available tab . These are all plugins - installed plugins . |
17,068 | public Plugin getPlugin ( String artifactId ) { Data dt = getData ( ) ; if ( dt == null ) return null ; return dt . plugins . get ( artifactId ) ; } | Gets the information about a specific plugin . |
17,069 | public String getConnectionCheckUrl ( ) { Data dt = getData ( ) ; if ( dt == null ) return "http://www.google.com/" ; return dt . connectionCheckUrl ; } | Gets a URL for the Internet connection check . |
17,070 | public List < Plugin > getUpdates ( ) { Data data = getData ( ) ; if ( data == null ) return Collections . emptyList ( ) ; List < Plugin > r = new ArrayList < > ( ) ; for ( PluginWrapper pw : Jenkins . getInstance ( ) . getPluginManager ( ) . getPlugins ( ) ) { Plugin p = pw . getUpdateInfo ( ) ; if ( p != null ) r . add ( p ) ; } return r ; } | Returns the list of plugins that are updates to currently installed ones . |
17,071 | public boolean hasUpdates ( ) { Data data = getData ( ) ; if ( data == null ) return false ; for ( PluginWrapper pw : Jenkins . getInstance ( ) . getPluginManager ( ) . getPlugins ( ) ) { if ( ! pw . isBundled ( ) && pw . getUpdateInfo ( ) != null ) return true ; } return false ; } | Does any of the plugin has updates? |
17,072 | @ Restricted ( NoExternalUse . class ) public String getMetadataUrlForDownloadable ( String downloadable ) { String siteUrl = getUrl ( ) ; String updateSiteMetadataUrl = null ; int baseUrlEnd = siteUrl . indexOf ( "update-center.json" ) ; if ( baseUrlEnd != - 1 ) { String siteBaseUrl = siteUrl . substring ( 0 , baseUrlEnd ) ; updateSiteMetadataUrl = siteBaseUrl + "updates/" + downloadable ; } else { LOGGER . log ( Level . WARNING , "Url {0} does not look like an update center:" , siteUrl ) ; } return updateSiteMetadataUrl ; } | URL which exposes the metadata location in a specific update site . |
17,073 | public void invalidate ( ) throws IOException { if ( roles != null ) { roles = null ; timestamp = System . currentTimeMillis ( ) ; user . save ( ) ; } } | Removes the recorded information |
17,074 | public void onChangeLogParsed ( Run < ? , ? > build , SCM scm , TaskListener listener , ChangeLogSet < ? > changelog ) throws Exception { if ( build instanceof AbstractBuild && listener instanceof BuildListener && Util . isOverridden ( SCMListener . class , getClass ( ) , "onChangeLogParsed" , AbstractBuild . class , BuildListener . class , ChangeLogSet . class ) ) { onChangeLogParsed ( ( AbstractBuild ) build , ( BuildListener ) listener , changelog ) ; } } | Called once the changelog is determined . |
17,075 | @ Initializer ( after = JOB_LOADED ) public static void installDefaultQueueSorter ( ) { ExtensionList < QueueSorter > all = all ( ) ; if ( all . isEmpty ( ) ) return ; Queue q = Jenkins . getInstance ( ) . getQueue ( ) ; if ( q . getSorter ( ) != null ) return ; q . setSorter ( all . get ( 0 ) ) ; if ( all . size ( ) > 1 ) LOGGER . warning ( "Multiple QueueSorters are registered. Only the first one is used and the rest are ignored: " + all ) ; } | Installs the default queue sorter . |
17,076 | public BeanDefinition getBeanDefinition ( String name ) { if ( ! getSpringConfig ( ) . containsBean ( name ) ) return null ; return getSpringConfig ( ) . getBeanConfig ( name ) . getBeanDefinition ( ) ; } | Retrieves a BeanDefinition for the given name |
17,077 | public Map < String , BeanDefinition > getBeanDefinitions ( ) { Map < String , BeanDefinition > beanDefinitions = new HashMap < > ( ) ; for ( String beanName : getSpringConfig ( ) . getBeanNames ( ) ) { BeanDefinition bd = getSpringConfig ( ) . getBeanConfig ( beanName ) . getBeanDefinition ( ) ; beanDefinitions . put ( beanName , bd ) ; } return beanDefinitions ; } | Retrieves all BeanDefinitions for this BeanBuilder |
17,078 | public Object methodMissing ( String name , Object arg ) { Object [ ] args = ( Object [ ] ) arg ; if ( args . length == 0 ) throw new MissingMethodException ( name , getClass ( ) , args ) ; if ( args [ 0 ] instanceof Closure ) { return invokeBeanDefiningMethod ( name , args ) ; } else if ( args [ 0 ] instanceof Class || args [ 0 ] instanceof RuntimeBeanReference || args [ 0 ] instanceof Map ) { return invokeBeanDefiningMethod ( name , args ) ; } else if ( args . length > 1 && args [ args . length - 1 ] instanceof Closure ) { return invokeBeanDefiningMethod ( name , args ) ; } WebApplicationContext ctx = springConfig . getUnrefreshedApplicationContext ( ) ; MetaClass mc = DefaultGroovyMethods . getMetaClass ( ctx ) ; if ( ! mc . respondsTo ( ctx , name , args ) . isEmpty ( ) ) { return mc . invokeMethod ( ctx , name , args ) ; } return this ; } | This method is invoked by Groovy when a method that s not defined in Java is invoked . We use that as a syntax for bean definition . |
17,079 | public void setProperty ( String name , Object value ) { if ( currentBeanConfig != null ) { if ( value instanceof GString ) value = value . toString ( ) ; if ( addToDeferred ( currentBeanConfig , name , value ) ) { return ; } else if ( value instanceof Closure ) { BeanConfiguration current = currentBeanConfig ; try { Closure callable = ( Closure ) value ; Class parameterType = callable . getParameterTypes ( ) [ 0 ] ; if ( parameterType . equals ( Object . class ) ) { currentBeanConfig = springConfig . createSingletonBean ( "" ) ; callable . call ( new Object [ ] { currentBeanConfig } ) ; } else { currentBeanConfig = springConfig . createSingletonBean ( parameterType ) ; callable . call ( null ) ; } value = currentBeanConfig . getBeanDefinition ( ) ; } finally { currentBeanConfig = current ; } } currentBeanConfig . addProperty ( name , value ) ; } else { binding . put ( name , value ) ; } } | This method overrides property setting in the scope of the BeanBuilder to set properties on the current BeanConfiguration |
17,080 | private Object manageMapIfNecessary ( Map < Object , Object > value ) { boolean containsRuntimeRefs = false ; for ( Entry < Object , Object > e : value . entrySet ( ) ) { Object v = e . getValue ( ) ; if ( v instanceof RuntimeBeanReference ) { containsRuntimeRefs = true ; } if ( v instanceof BeanConfiguration ) { BeanConfiguration c = ( BeanConfiguration ) v ; e . setValue ( c . getBeanDefinition ( ) ) ; containsRuntimeRefs = true ; } } if ( containsRuntimeRefs ) { ManagedMap m = new ManagedMap ( ) ; m . putAll ( value ) ; return m ; } return value ; } | Checks whether there are any runtime refs inside a Map and converts it to a ManagedMap if necessary |
17,081 | private Object manageListIfNecessary ( List < Object > value ) { boolean containsRuntimeRefs = false ; for ( ListIterator < Object > i = value . listIterator ( ) ; i . hasNext ( ) ; ) { Object e = i . next ( ) ; if ( e instanceof RuntimeBeanReference ) { containsRuntimeRefs = true ; } if ( e instanceof BeanConfiguration ) { BeanConfiguration c = ( BeanConfiguration ) e ; i . set ( c . getBeanDefinition ( ) ) ; containsRuntimeRefs = true ; } } if ( containsRuntimeRefs ) { List tmp = new ManagedList ( ) ; tmp . addAll ( value ) ; value = tmp ; } return value ; } | Checks whether there are any runtime refs inside the list and converts it to a ManagedList if necessary |
17,082 | public SubText subText ( int start , int end ) { return new SubText ( start , end < 0 ? text . length ( ) + 1 + end : end ) ; } | Returns a subtext . |
17,083 | public boolean readFromDefaultLocations ( ) { final File home = new File ( System . getProperty ( "user.home" ) ) ; boolean read = false ; for ( String path : new String [ ] { ".ssh/id_rsa" , ".ssh/id_dsa" , ".ssh/identity" } ) { final File key = new File ( home , path ) ; if ( ! key . exists ( ) ) continue ; try { readFrom ( key ) ; read = true ; } catch ( IOException e ) { LOGGER . log ( FINE , "Failed to load " + key , e ) ; } catch ( GeneralSecurityException e ) { LOGGER . log ( FINE , "Failed to load " + key , e ) ; } } return read ; } | Read keys from default keyFiles |
17,084 | public void readFrom ( File keyFile ) throws IOException , GeneralSecurityException { final String password = isPemEncrypted ( keyFile ) ? askForPasswd ( keyFile . getCanonicalPath ( ) ) : null ; privateKeys . add ( loadKey ( keyFile , password ) ) ; } | Read key from keyFile . |
17,085 | @ Restricted ( NoExternalUse . class ) public DiskSpace markNodeOfflineIfDiskspaceIsTooLow ( Computer c ) { DiskSpace size = ( DiskSpace ) super . data ( c ) ; if ( size != null && size . size < getThresholdBytes ( ) ) { size . setTriggered ( this . getClass ( ) , true ) ; if ( getDescriptor ( ) . markOffline ( c , size ) ) { LOGGER . warning ( Messages . DiskSpaceMonitor_MarkedOffline ( c . getDisplayName ( ) ) ) ; } } return size ; } | Marks the given node as offline if free disk space is below the configured threshold . |
17,086 | private long seek ( Run < ? , ? > run ) throws IOException { class RingBuffer { long [ ] lastNlines = new long [ n ] ; int ptr = 0 ; RingBuffer ( ) { for ( int i = 0 ; i < n ; i ++ ) lastNlines [ i ] = - 1 ; } void add ( long pos ) { lastNlines [ ptr ] = pos ; ptr = ( ptr + 1 ) % lastNlines . length ; } long get ( ) { long v = lastNlines [ ptr ] ; if ( v < 0 ) return lastNlines [ 0 ] ; return v ; } } RingBuffer rb = new RingBuffer ( ) ; try ( InputStream in = run . getLogInputStream ( ) ) { byte [ ] buf = new byte [ 4096 ] ; int len ; byte prev = 0 ; long pos = 0 ; boolean prevIsNL = false ; while ( ( len = in . read ( buf ) ) >= 0 ) { for ( int i = 0 ; i < len ; i ++ ) { byte ch = buf [ i ] ; boolean isNL = ch == '\r' || ch == '\n' ; if ( ! isNL && prevIsNL ) rb . add ( pos ) ; if ( isNL && prevIsNL && ! ( prev == '\r' && ch == '\n' ) ) rb . add ( pos ) ; pos ++ ; prev = ch ; prevIsNL = isNL ; } } return rb . get ( ) ; } } | Find the byte offset in the log input stream that marks last N lines . |
17,087 | public void write ( int b ) throws IOException { cache [ cachePosition ] = ( byte ) b ; cachePosition ++ ; if ( cachePosition == cache . length ) flushCache ( ) ; } | Write the specified byte to our output stream . |
17,088 | @ SuppressWarnings ( { "ConstantConditions" } ) public void load ( ) { Class < ? extends RepositoryBrowser > rb = repositoryBrowser ; super . load ( ) ; if ( repositoryBrowser != rb ) { try { Field f = SCMDescriptor . class . getDeclaredField ( "repositoryBrowser" ) ; f . setAccessible ( true ) ; f . set ( this , rb ) ; } catch ( NoSuchFieldException | IllegalAccessException e ) { LOGGER . log ( WARNING , "Failed to overwrite the repositoryBrowser field" , e ) ; } } } | causing the field to be persisted and overwritten on the load method . |
17,089 | void report ( Class c ) { if ( ! get ( ) . contains ( c ) ) { try { append ( c . getName ( ) ) ; } catch ( IOException e ) { LOGGER . log ( Level . WARNING , "Failed to persist " + file , e ) ; } } } | This method gets called every time we see a new type of callable that we reject so that we can persist the list . |
17,090 | public List < RejectedCallable > describe ( ) { List < RejectedCallable > l = new ArrayList < > ( ) ; for ( Class c : get ( ) ) { if ( ! whitelist . contains ( c . getName ( ) ) ) l . add ( new RejectedCallable ( c ) ) ; } return l ; } | Return the object that helps the UI rendering by providing the details . |
17,091 | public final Object [ ] getItems ( ) { List < T > r = new ArrayList < > ( ) ; for ( T t : this ) r . add ( t ) ; return r . toArray ( ) ; } | method for the remote API . |
17,092 | public String getAdminAddress ( ) { String v = adminAddress ; if ( v == null ) v = Messages . Mailer_Address_Not_Configured ( ) ; return v ; } | Gets the service administrator e - mail address . |
17,093 | private void updateSecureSessionFlag ( ) { try { ServletContext context = Jenkins . get ( ) . servletContext ; Method m ; try { m = context . getClass ( ) . getMethod ( "getSessionCookieConfig" ) ; } catch ( NoSuchMethodException x ) { LOGGER . log ( Level . FINE , "Failed to set secure cookie flag" , x ) ; return ; } Object sessionCookieConfig = m . invoke ( context ) ; Class scc = Class . forName ( "javax.servlet.SessionCookieConfig" ) ; Method setSecure = scc . getMethod ( "setSecure" , boolean . class ) ; boolean v = fixNull ( jenkinsUrl ) . startsWith ( "https" ) ; setSecure . invoke ( sessionCookieConfig , v ) ; } catch ( InvocationTargetException e ) { if ( e . getTargetException ( ) instanceof IllegalStateException ) { return ; } LOGGER . log ( Level . WARNING , "Failed to set secure cookie flag" , e ) ; } catch ( Exception e ) { LOGGER . log ( Level . WARNING , "Failed to set secure cookie flag" , e ) ; } } | If the Jenkins URL starts from https force the secure session flag |
17,094 | public OutputStream write ( ) throws IOException { if ( gz . exists ( ) ) gz . delete ( ) ; try { return Files . newOutputStream ( file . toPath ( ) ) ; } catch ( InvalidPathException e ) { throw new IOException ( e ) ; } } | Gets the OutputStream to write to the file . |
17,095 | public InputStream read ( ) throws IOException { if ( file . exists ( ) ) try { return Files . newInputStream ( file . toPath ( ) ) ; } catch ( InvalidPathException e ) { throw new IOException ( e ) ; } if ( gz . exists ( ) ) try { return new GZIPInputStream ( Files . newInputStream ( gz . toPath ( ) ) ) ; } catch ( InvalidPathException e ) { throw new IOException ( e ) ; } throw new FileNotFoundException ( file . getName ( ) ) ; } | Reads the contents of a file . |
17,096 | public String loadAsString ( ) throws IOException { long sizeGuess ; if ( file . exists ( ) ) sizeGuess = file . length ( ) ; else if ( gz . exists ( ) ) sizeGuess = gz . length ( ) * 2 ; else return "" ; StringBuilder str = new StringBuilder ( ( int ) sizeGuess ) ; try ( InputStream is = read ( ) ; Reader r = new InputStreamReader ( is ) ) { char [ ] buf = new char [ 8192 ] ; int len ; while ( ( len = r . read ( buf , 0 , buf . length ) ) > 0 ) str . append ( buf , 0 , len ) ; } return str . toString ( ) ; } | Loads the file content as a string . |
17,097 | public void compress ( ) { compressionThread . submit ( new Runnable ( ) { public void run ( ) { try { try ( InputStream in = read ( ) ; OutputStream os = Files . newOutputStream ( gz . toPath ( ) ) ; OutputStream out = new GZIPOutputStream ( os ) ) { org . apache . commons . io . IOUtils . copy ( in , out ) ; } file . delete ( ) ; } catch ( IOException e ) { LOGGER . log ( Level . WARNING , "Failed to compress " + file , e ) ; gz . delete ( ) ; } } } ) ; } | Asynchronously schedules the compression of this file . |
17,098 | public < V > V run ( Callable < V , IOException > callable ) throws IOException { return callable . call ( ) ; } | Does some calculations in batch . For a remote file this can be much faster than doing the corresponding operations one by one as separate requests . The default implementation just calls the block directly . |
17,099 | public String getIdentityPublicKey ( ) { RSAPublicKey key = InstanceIdentityProvider . RSA . getPublicKey ( ) ; return key == null ? null : new String ( Base64 . encodeBase64 ( key . getEncoded ( ) ) , Charset . forName ( "UTF-8" ) ) ; } | Gets the Base64 encoded public key that forms part of this instance s identity keypair . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.