Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

TRIVIAL: clean up httpclient logging #786

Merged
merged 1 commit into from

4 participants

@jdillon
Owner

No description provided.

@cstamas
Owner

+1

@ifedorenko ifedorenko commented on the diff
.../sonatype/nexus/apachehttpclient/Hc4ProviderBase.java
@@ -181,7 +171,7 @@ protected void configureAuthentication( final DefaultHttpClient httpClient,
authScope = proxyHost.toHostString() + " proxy";
}
- List<String> authorisationPreference = new ArrayList<String>( 2 );
+ List<String> authorisationPreference = Lists.newArrayListWithExpectedSize(3);

Logging cleanup?

@jdillon Owner
jdillon added a note

Obviously not :-P I did notice when looking over the logging here that when ntlm was configured that the size is expected to be 3 not 2. Its a minor and safe optimization which I didn't bother to track in a separate change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@adreghiciu
Owner

+1

@jdillon jdillon merged commit 0ebd3ed into master
@jdillon jdillon deleted the httpclient-logging-tidy branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 22, 2013
  1. @jdillon

    Tidy logging, javadocs, ...

    jdillon authored
This page is out of date. Refresh to see the latest.
View
4 nexus-core/src/main/java/org/sonatype/nexus/apachehttpclient/EvictingThread.java
@@ -40,7 +40,7 @@
EvictingThread( final ClientConnectionManager clientConnectionManager, final long idleTimeMillis, final long delay )
{
super( "HC4x-EvictingThread" );
- Preconditions.checkArgument( idleTimeMillis > -1, "Keep alive period in milliseconds cannot be negative." );
+ Preconditions.checkArgument( idleTimeMillis > -1, "Keep alive period in milliseconds cannot be negative" );
this.clientConnectionManager = Preconditions.checkNotNull( clientConnectionManager );
this.idleTimeMillis = idleTimeMillis;
this.delay = delay;
@@ -87,6 +87,6 @@ public void run()
{
// bye bye
}
- LOGGER.debug( "Stopped '{}'", getName(), delay );
+ LOGGER.debug( "Stopped '{}'", getName() );
}
}
View
26 nexus-core/src/main/java/org/sonatype/nexus/apachehttpclient/Hc4ProviderBase.java
@@ -12,8 +12,6 @@
*/
package org.sonatype.nexus.apachehttpclient;
-import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -23,6 +21,8 @@
import javax.inject.Named;
import javax.inject.Singleton;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import org.apache.http.HttpHost;
import org.apache.http.HttpVersion;
import org.apache.http.auth.AuthScope;
@@ -81,8 +81,6 @@
private final UserAgentBuilder userAgentBuilder;
/**
- * Constructor.
- *
* @param userAgentBuilder UA builder component, must not be {@code null}.
*/
@Inject
@@ -128,8 +126,6 @@ protected HttpParams createHttpParams( final RemoteStorageContext context )
/**
* Returns the maximum Keep-Alive duration in milliseconds.
- *
- * @return default Keep-Alive duration in milliseconds.
*/
protected long getKeepAliveMaxDuration()
{
@@ -138,9 +134,6 @@ protected long getKeepAliveMaxDuration()
/**
* Returns the connection timeout in milliseconds. The timeout until connection is established.
- *
- * @param context
- * @return the connection timeout in milliseconds.
*/
protected int getConnectionTimeout( final RemoteStorageContext context )
{
@@ -157,9 +150,6 @@ protected int getConnectionTimeout( final RemoteStorageContext context )
/**
* Returns the SO_SOCKET timeout in milliseconds. The timeout for waiting for data on established connection.
- *
- * @param context
- * @return the SO_SOCKET timeout in milliseconds.
*/
protected int getSoTimeout( final RemoteStorageContext context )
{
@@ -181,7 +171,7 @@ protected void configureAuthentication( final DefaultHttpClient httpClient,
authScope = proxyHost.toHostString() + " proxy";
}
- List<String> authorisationPreference = new ArrayList<String>( 2 );
+ List<String> authorisationPreference = Lists.newArrayListWithExpectedSize(3);

Logging cleanup?

@jdillon Owner
jdillon added a note

Obviously not :-P I did notice when looking over the logging here that when ntlm was configured that the size is expected to be 3 not 2. Its a minor and safe optimization which I didn't bother to track in a separate change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
authorisationPreference.add( AuthPolicy.DIGEST );
authorisationPreference.add( AuthPolicy.BASIC );
Credentials credentials = null;
@@ -194,7 +184,7 @@ else if ( ras instanceof NtlmRemoteAuthenticationSettings )
final NtlmRemoteAuthenticationSettings nras = (NtlmRemoteAuthenticationSettings) ras;
// Using NTLM auth, adding it as first in policies
authorisationPreference.add( 0, AuthPolicy.NTLM );
- getLogger().info( "... {} authentication setup for NTLM domain '{}'", authScope, nras.getNtlmDomain() );
+ getLogger().debug("{} authentication setup for NTLM domain '{}'", authScope, nras.getNtlmDomain());
credentials = new NTCredentials(
nras.getUsername(), nras.getPassword(), nras.getNtlmHost(), nras.getNtlmDomain()
);
@@ -203,8 +193,8 @@ else if ( ras instanceof UsernamePasswordRemoteAuthenticationSettings )
{
final UsernamePasswordRemoteAuthenticationSettings uras =
(UsernamePasswordRemoteAuthenticationSettings) ras;
- getLogger().info( "... {} authentication setup for remote storage with username '{}'", authScope,
- uras.getUsername() );
+ getLogger().debug("{} authentication setup for remote storage with username '{}'", authScope,
+ uras.getUsername());
credentials = new UsernamePasswordCredentials( uras.getUsername(), uras.getPassword() );
}
@@ -228,7 +218,7 @@ protected void configureProxy( final DefaultHttpClient httpClient, final RemoteP
{
if ( remoteProxySettings.isEnabled() )
{
- getLogger().info( "... proxy setup with host '{}'", remoteProxySettings.getHostname() );
+ getLogger().debug("proxy setup with host '{}'", remoteProxySettings.getHostname());
final HttpHost proxy = new HttpHost( remoteProxySettings.getHostname(), remoteProxySettings.getPort() );
httpClient.getParams().setParameter( ConnRoutePNames.DEFAULT_PROXY, proxy );
@@ -236,7 +226,7 @@ protected void configureProxy( final DefaultHttpClient httpClient, final RemoteP
// check if we have non-proxy hosts
if ( remoteProxySettings.getNonProxyHosts() != null && !remoteProxySettings.getNonProxyHosts().isEmpty() )
{
- final Set<Pattern> nonProxyHostPatterns = new HashSet<Pattern>(
+ final Set<Pattern> nonProxyHostPatterns = Sets.newHashSetWithExpectedSize(
remoteProxySettings.getNonProxyHosts().size()
);
for ( String nonProxyHostRegex : remoteProxySettings.getNonProxyHosts() )
View
22 nexus-core/src/main/java/org/sonatype/nexus/apachehttpclient/Hc4ProviderImpl.java
@@ -125,8 +125,6 @@
private final PoolingClientConnectionManagerMBeanInstaller jmxInstaller;
/**
- * Constructor.
- *
* @param applicationConfiguration the Nexus {@link ApplicationConfiguration}, must not be {@code null}.
* @param userAgentBuilder UA builder component, must not be {@code null}.
* @param eventBus the event bus, must not be {@code null}.
@@ -149,17 +147,19 @@ public Hc4ProviderImpl( final ApplicationConfiguration applicationConfiguration,
this.eventBus.register( this );
this.jmxInstaller.register( sharedConnectionManager );
getLogger().info(
- "{} started (connectionPoolMaxSize {}, connectionPoolSize {}, connectionPoolIdleTime {} ms, connectionPoolTimeout {} ms, keepAliveMaxDuration {} ms)",
- getClass().getSimpleName(), getConnectionPoolMaxSize(), getConnectionPoolSize(),
- getConnectionPoolIdleTime(), getConnectionPoolTimeout(), getKeepAliveMaxDuration() );
+ "Started (connectionPoolMaxSize {}, connectionPoolSize {}, connectionPoolIdleTime {} ms, connectionPoolTimeout {} ms, keepAliveMaxDuration {} ms)",
+ getConnectionPoolMaxSize(),
+ getConnectionPoolSize(),
+ getConnectionPoolIdleTime(),
+ getConnectionPoolTimeout(),
+ getKeepAliveMaxDuration()
+ );
}
// configuration
/**
* Returns the pool max size.
- *
- * @return pool max size
*/
protected int getConnectionPoolMaxSize()
{
@@ -168,8 +168,6 @@ protected int getConnectionPoolMaxSize()
/**
* Returns the pool size per route.
- *
- * @return pool per route size
*/
protected int getConnectionPoolSize()
{
@@ -178,8 +176,6 @@ protected int getConnectionPoolSize()
/**
* Returns the connection pool idle (idle as unused but pooled) time in milliseconds.
- *
- * @return idle time in milliseconds.
*/
protected long getConnectionPoolIdleTime()
{
@@ -188,8 +184,6 @@ protected long getConnectionPoolIdleTime()
/**
* Returns the pool timeout in milliseconds.
- *
- * @return pool timeout in milliseconds.
*/
protected long getConnectionPoolTimeout()
{
@@ -208,7 +202,7 @@ public synchronized void shutdown()
jmxInstaller.unregister();
sharedConnectionManager.shutdown();
eventBus.unregister( this );
- getLogger().info( "{} stopped.", getClass().getSimpleName() );
+ getLogger().info( "Stopped" );
}
@Subscribe
View
4 ...e/src/main/java/org/sonatype/nexus/apachehttpclient/NexusConnectionKeepAliveStrategy.java
@@ -35,8 +35,6 @@
private final long maxKeepAliveDuration;
/**
- * Constructor.
- *
* @param maxKeepAliveDuration the max duration in millis for how long to pool the connection.
*/
public NexusConnectionKeepAliveStrategy( final long maxKeepAliveDuration )
@@ -52,8 +50,6 @@ public NexusConnectionKeepAliveStrategy( final long maxKeepAliveDuration )
* idle. Nexus by default does not "believe" much to remote servers, and will never
* keep connection pooled "forever", nor will keep it pooled for unreasonable long time.
*
- * @param response
- * @param context
* @return the duration of time which this connection can be safely kept idle in pool.
*/
public long getKeepAliveDuration( HttpResponse response, HttpContext context )
Something went wrong with that request. Please try again.