1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 18:59:41 +02:00

Make JUL Loggers final (SMACK-536)

This commit is contained in:
Florian Schmaus 2014-02-26 21:38:02 +01:00
parent f0c6d1f1d3
commit 54a421e84e
30 changed files with 109 additions and 109 deletions

View file

@ -39,7 +39,7 @@ import java.util.logging.Logger;
* @author Matt Tucker
*/
public class AccountManager {
private static Logger logger = Logger.getLogger(AccountManager.class.getName());
private static final Logger LOGGER = Logger.getLogger(AccountManager.class.getName());
private Connection connection;
private Registration info = null;
@ -134,7 +134,7 @@ public class AccountManager {
}
}
catch (XMPPException xe) {
logger.log(Level.SEVERE, "Error retrieving account attributes from server", xe);
LOGGER.log(Level.SEVERE, "Error retrieving account attributes from server", xe);
}
return Collections.emptySet();
}
@ -155,7 +155,7 @@ public class AccountManager {
return info.getAttributes().get(name);
}
catch (XMPPException xe) {
logger.log(Level.SEVERE, "Error retrieving account attribute " + name + " info from server", xe);
LOGGER.log(Level.SEVERE, "Error retrieving account attribute " + name + " info from server", xe);
}
return null;
}
@ -175,7 +175,7 @@ public class AccountManager {
return info.getInstructions();
}
catch (XMPPException xe) {
logger.log(Level.SEVERE, "Error retrieving account instructions from server", xe);
LOGGER.log(Level.SEVERE, "Error retrieving account instructions from server", xe);
return null;
}
}

View file

@ -81,7 +81,7 @@ import org.jivesoftware.smack.packet.Presence;
* @author Guenther Niess
*/
public abstract class Connection {
private static Logger log = Logger.getLogger(Connection.class.getName());
private static final Logger LOGGER = Logger.getLogger(Connection.class.getName());
/**
* Counter to uniquely identify connections that are created.
@ -793,7 +793,7 @@ public abstract class Connection {
debuggerClass = Class.forName(className);
}
catch (Exception e) {
log.warning("Unabled to instantiate debugger class " + className);
LOGGER.warning("Unabled to instantiate debugger class " + className);
}
}
if (debuggerClass == null) {
@ -807,7 +807,7 @@ public abstract class Connection {
Class.forName("org.jivesoftware.smack.debugger.LiteDebugger");
}
catch (Exception ex2) {
log.warning("Unabled to instantiate either Smack debugger class");
LOGGER.warning("Unabled to instantiate either Smack debugger class");
}
}
}

View file

@ -44,7 +44,7 @@ import java.util.logging.Logger;
*/
class PacketReader {
private static Logger log = Logger.getLogger(PacketReader.class.getName());
private static final Logger LOGGER = Logger.getLogger(PacketReader.class.getName());
private Thread readerThread;
private ExecutorService listenerExecutor;
@ -135,7 +135,7 @@ class PacketReader {
catch (Exception e) {
// Catch and print any exception so we can recover
// from a faulty listener and finish the shutdown process
log.log(Level.SEVERE, "Error in listener while closing connection", e);
LOGGER.log(Level.SEVERE, "Error in listener while closing connection", e);
}
}
}
@ -157,7 +157,7 @@ class PacketReader {
parser.setInput(connection.reader);
}
catch (XmlPullParserException xppe) {
log.log(Level.WARNING, "Error while resetting parser", xppe);
LOGGER.log(Level.WARNING, "Error while resetting parser", xppe);
}
}
@ -457,7 +457,7 @@ class PacketReader {
try {
listenerWrapper.notifyListener(packet);
} catch (Exception e) {
log.log(Level.SEVERE, "Exception in packet listener", e);
LOGGER.log(Level.SEVERE, "Exception in packet listener", e);
}
}
}

View file

@ -37,7 +37,7 @@ import java.util.logging.Logger;
* @author Matt Tucker
*/
class PacketWriter {
private static Logger log = Logger.getLogger(PacketWriter.class.getName());
private static final Logger LOGGER = Logger.getLogger(PacketWriter.class.getName());
private Thread writerThread;
private Writer writer;
@ -88,7 +88,7 @@ class PacketWriter {
queue.put(packet);
}
catch (InterruptedException ie) {
log.log(Level.SEVERE, "Failed to queue packet to send to server: " + packet.toString(), ie);
LOGGER.log(Level.SEVERE, "Failed to queue packet to send to server: " + packet.toString(), ie);
return;
}
synchronized (queue) {
@ -172,7 +172,7 @@ class PacketWriter {
writer.flush();
}
catch (Exception e) {
log.warning("Error flushing queue during shutdown, ignore and continue");
LOGGER.warning("Error flushing queue during shutdown, ignore and continue");
}
// Delete the queue contents (hopefully nothing is left).

View file

@ -34,7 +34,7 @@ import java.util.logging.Logger;
* @author Francisco Vives
*/
public class ReconnectionManager implements ConnectionListener {
private static Logger log = Logger.getLogger(ReconnectionManager.class.getName());
private static final Logger LOGGER = Logger.getLogger(ReconnectionManager.class.getName());
// Holds the connection to the server
private Connection connection;
@ -134,7 +134,7 @@ public class ReconnectionManager implements ConnectionListener {
.notifyAttemptToReconnectIn(remainingSeconds);
}
catch (InterruptedException e1) {
log.warning("Sleeping thread interrupted");
LOGGER.warning("Sleeping thread interrupted");
// Notify the reconnection has failed
ReconnectionManager.this.notifyReconnectionFailed(e1);
}

View file

@ -55,7 +55,7 @@ public final class SmackConfiguration {
private static final String SMACK_VERSION;
private static final String DEFAULT_CONFIG_FILE = "classpath:org.jivesoftware.smack/smack-config.xml";
private static final Logger log = Logger.getLogger(SmackConfiguration.class.getName());
private static final Logger LOGGER = Logger.getLogger(SmackConfiguration.class.getName());
private static int defaultPacketReplyTimeout = 5000;
private static int packetCollectorSize = 5000;
@ -72,7 +72,7 @@ public final class SmackConfiguration {
is.read(buf);
smackVersion = new String(buf, "UTF-8");
} catch(Exception e) {
log.log(Level.SEVERE, "Could not determine Smack version", e);
LOGGER.log(Level.SEVERE, "Could not determine Smack version", e);
smackVersion = "unkown";
}
SMACK_VERSION = smackVersion;
@ -271,7 +271,7 @@ public final class SmackConfiguration {
cfgFileStream.close();
}
catch (IOException e) {
log.log(Level.SEVERE, "Error while closing config file input stream", e);
LOGGER.log(Level.SEVERE, "Error while closing config file input stream", e);
}
}
@ -284,7 +284,7 @@ public final class SmackConfiguration {
name = parser.getName();
if (eventType == XmlPullParser.START_TAG && "className".equals(name)) {
if (disabledSmackClasses.contains(name)) {
log.info("Not loading disabled Smack class " + name);
LOGGER.info("Not loading disabled Smack class " + name);
}
else {
String classToLoad = parser.nextText();
@ -316,7 +316,7 @@ public final class SmackConfiguration {
else {
logLevel = Level.WARNING;
}
log.log(logLevel, "A startup class [" + className
LOGGER.log(logLevel, "A startup class [" + className
+ "] specified in smack-config.xml could not be loaded: ");
if (!optional)
throw cnfe;

View file

@ -33,7 +33,7 @@ import org.jivesoftware.smack.util.FileUtils;
*/
public class LoggingInitializer implements SmackInitializer {
private static Logger log = Logger.getLogger(LoggingInitializer.class.getName());
private static final Logger LOGGER = Logger.getLogger(LoggingInitializer.class.getName());
private List<Exception> exceptions = new LinkedList<Exception>();
@ -43,7 +43,7 @@ public class LoggingInitializer implements SmackInitializer {
LogManager.getLogManager().readConfiguration(FileUtils.getStreamForUrl("classpath:org.jivesofware.smack/jul.properties", null));
}
catch (Exception e) {
log .log(Level.WARNING, "Could not initialize Java Logging from default file.", e);
LOGGER.log(Level.WARNING, "Could not initialize Java Logging from default file.", e);
exceptions.add(e);
}
}

View file

@ -35,7 +35,7 @@ import org.jivesoftware.smack.util.FileUtils;
*
*/
public abstract class UrlProviderFileInitializer implements SmackInitializer {
private static final Logger log = Logger.getLogger(UrlProviderFileInitializer.class.getName());
private static final Logger LOGGER = Logger.getLogger(UrlProviderFileInitializer.class.getName());
private List<Exception> exceptions = new LinkedList<Exception>();
@ -47,18 +47,18 @@ public abstract class UrlProviderFileInitializer implements SmackInitializer {
InputStream is = FileUtils.getStreamForUrl(filePath, getClassLoader());
if (is != null) {
log.log(Level.INFO, "Loading providers for file [" + filePath + "]");
LOGGER.log(Level.INFO, "Loading providers for file [" + filePath + "]");
ProviderFileLoader pfl = new ProviderFileLoader(is);
ProviderManager.getInstance().addLoader(pfl);
exceptions.addAll(pfl.getLoadingExceptions());
}
else {
log.log(Level.WARNING, "No input stream created for " + filePath);
LOGGER.log(Level.WARNING, "No input stream created for " + filePath);
exceptions.add(new IOException("No input stream created for " + filePath));
}
}
catch (Exception e) {
log.log(Level.SEVERE, "Error trying to load provider file " + filePath, e);
LOGGER.log(Level.SEVERE, "Error trying to load provider file " + filePath, e);
exceptions.add(e);
}
}

View file

@ -40,7 +40,7 @@ import java.util.logging.Logger;
* @author Matt Tucker
*/
public abstract class Packet {
private static Logger log = Logger.getLogger(Packet.class.getName());
private static final Logger LOGGER = Logger.getLogger(Packet.class.getName());
protected static final String DEFAULT_LANGUAGE =
java.util.Locale.getDefault().getLanguage().toLowerCase();
@ -411,7 +411,7 @@ public abstract class Packet {
buf.append(encodedVal).append("</value>");
}
catch (Exception e) {
log.log(Level.SEVERE, "Error encoding java object", e);
LOGGER.log(Level.SEVERE, "Error encoding java object", e);
}
finally {
if (out != null) {

View file

@ -27,11 +27,11 @@ import java.util.logging.Logger;
*
*/
public class ExceptionLoggingCallback extends ParsingExceptionCallback {
private static Logger log = Logger.getLogger(ExceptionLoggingCallback.class.getName());
private static final Logger LOGGER = Logger.getLogger(ExceptionLoggingCallback.class.getName());
@Override
public void handleUnparsablePacket(UnparsablePacket unparsed) throws Exception {
log.log(Level.SEVERE, "Smack message parsing exception: ", unparsed.getParsingException());
log.severe("Unparsed content: " + unparsed.getContent());
LOGGER.log(Level.SEVERE, "Smack message parsing exception: ", unparsed.getParsingException());
LOGGER.severe("Unparsed content: " + unparsed.getContent());
}
}

View file

@ -38,7 +38,7 @@ import org.xmlpull.v1.XmlPullParser;
*
*/
public class ProviderFileLoader implements ProviderLoader {
private final static Logger log = Logger.getLogger(ProviderFileLoader.class.getName());
private static final Logger LOGGER = Logger.getLogger(ProviderFileLoader.class.getName());
private Collection<IQProviderInfo> iqProviders;
private Collection<ExtensionProviderInfo> extProviders;
@ -135,13 +135,13 @@ public class ProviderFileLoader implements ProviderLoader {
}
}
catch (ClassNotFoundException cnfe) {
log.log(Level.SEVERE, "Could not find provider class", cnfe);
LOGGER.log(Level.SEVERE, "Could not find provider class", cnfe);
exceptions.add(cnfe);
}
}
}
catch (IllegalArgumentException illExc) {
log.log(Level.SEVERE, "Invalid provider type found [" + typeName + "] when expecting iqProvider or extensionProvider", illExc);
LOGGER.log(Level.SEVERE, "Invalid provider type found [" + typeName + "] when expecting iqProvider or extensionProvider", illExc);
exceptions.add(illExc);
}
}
@ -150,7 +150,7 @@ public class ProviderFileLoader implements ProviderLoader {
while (eventType != XmlPullParser.END_DOCUMENT);
}
catch (Exception e){
log.log(Level.SEVERE, "Unknown error occurred while parsing provider file", e);
LOGGER.log(Level.SEVERE, "Unknown error occurred while parsing provider file", e);
}
finally {
try {

View file

@ -30,7 +30,7 @@ import java.util.logging.Logger;
*/
public class Base64
{
private static Logger log = Logger.getLogger(Base64.class.getName());
private static final Logger LOGGER = Logger.getLogger(Base64.class.getName());
/* ******** P U B L I C F I E L D S ******** */
@ -494,7 +494,7 @@ public class Base64
} // end try
catch( java.io.IOException e )
{
log.log(Level.SEVERE, "Error encoding object", e);
LOGGER.log(Level.SEVERE, "Error encoding object", e);
return null;
} // end catch
finally
@ -623,7 +623,7 @@ public class Base64
} // end try
catch( java.io.IOException e )
{
log.log(Level.SEVERE, "Error encoding bytes", e);
LOGGER.log(Level.SEVERE, "Error encoding bytes", e);
return null;
} // end catch
finally
@ -778,11 +778,11 @@ public class Base64
return 3;
}catch( Exception e){
log.log(Level.SEVERE, e.getMessage(), e);
log.severe(""+source[srcOffset]+ ": " + ( DECODABET[ source[ srcOffset ] ] ) );
log.severe(""+source[srcOffset+1]+ ": " + ( DECODABET[ source[ srcOffset + 1 ] ] ) );
log.severe(""+source[srcOffset+2]+ ": " + ( DECODABET[ source[ srcOffset + 2 ] ] ) );
log.severe(""+source[srcOffset+3]+ ": " + ( DECODABET[ source[ srcOffset + 3 ] ] ) );
LOGGER.log(Level.SEVERE, e.getMessage(), e);
LOGGER.severe(""+source[srcOffset]+ ": " + ( DECODABET[ source[ srcOffset ] ] ) );
LOGGER.severe(""+source[srcOffset+1]+ ": " + ( DECODABET[ source[ srcOffset + 1 ] ] ) );
LOGGER.severe(""+source[srcOffset+2]+ ": " + ( DECODABET[ source[ srcOffset + 2 ] ] ) );
LOGGER.severe(""+source[srcOffset+3]+ ": " + ( DECODABET[ source[ srcOffset + 3 ] ] ) );
return -1;
} // end catch
}
@ -840,7 +840,7 @@ public class Base64
} // end if: white space, equals sign or better
else
{
log.warning("Bad Base64 input character at " + i + ": " + source[i] + "(decimal)");
LOGGER.warning("Bad Base64 input character at " + i + ": " + source[i] + "(decimal)");
return null;
} // end else:
} // each input character
@ -968,12 +968,12 @@ public class Base64
} // end try
catch( java.io.IOException e )
{
log.log(Level.SEVERE, "Error reading object", e);
LOGGER.log(Level.SEVERE, "Error reading object", e);
obj = null;
} // end catch
catch( java.lang.ClassNotFoundException e )
{
log.log(Level.SEVERE, "Class not found for encoded object", e);
LOGGER.log(Level.SEVERE, "Class not found for encoded object", e);
obj = null;
} // end catch
finally
@ -1080,7 +1080,7 @@ public class Base64
// Check for size of file
if( file.length() > Integer.MAX_VALUE )
{
log.warning("File is too big for this convenience method (" + file.length() + " bytes).");
LOGGER.warning("File is too big for this convenience method (" + file.length() + " bytes).");
return null;
} // end if: file too big for int index
buffer = new byte[ (int)file.length() ];
@ -1101,7 +1101,7 @@ public class Base64
} // end try
catch( java.io.IOException e )
{
log.log(Level.SEVERE, "Error decoding from file " + filename, e);
LOGGER.log(Level.SEVERE, "Error decoding from file " + filename, e);
} // end catch: IOException
finally
{
@ -1149,7 +1149,7 @@ public class Base64
} // end try
catch( java.io.IOException e )
{
log.log(Level.SEVERE, "Error encoding from file " + filename, e);
LOGGER.log(Level.SEVERE, "Error encoding from file " + filename, e);
} // end catch: IOException
finally
{
@ -1176,7 +1176,7 @@ public class Base64
out.write( encoded.getBytes("US-ASCII") ); // Strict, 7-bit output.
} // end try
catch( java.io.IOException ex ) {
log.log(Level.SEVERE, "Error encoding file " + infile, ex);
LOGGER.log(Level.SEVERE, "Error encoding file " + infile, ex);
} // end catch
finally {
try { out.close(); }
@ -1202,7 +1202,7 @@ public class Base64
out.write( decoded );
} // end try
catch( java.io.IOException ex ) {
log.log(Level.SEVERE, "Error decoding file " + infile, ex);
LOGGER.log(Level.SEVERE, "Error decoding file " + infile, ex);
} // end catch
finally {
try { out.close(); }

View file

@ -47,7 +47,7 @@ import java.util.logging.Logger;
* @author Matt Tucker
*/
public class Cache<K, V> implements Map<K, V> {
private static Logger log = Logger.getLogger(Cache.class.getName());
private static final Logger LOGGER = Logger.getLogger(Cache.class.getName());
/**
* The map the keys and values are stored in.
*/
@ -382,7 +382,7 @@ public class Cache<K, V> implements Map<K, V> {
while (expireTime > node.timestamp) {
if (remove(node.object, true) == null) {
log.warning("Error attempting to remove(" + node.object.toString() + ") - cacheObject not found in cache!");
LOGGER.warning("Error attempting to remove(" + node.object.toString() + ") - cacheObject not found in cache!");
// remove from the ageList
node.remove();
}
@ -416,7 +416,7 @@ public class Cache<K, V> implements Map<K, V> {
for (int i=map.size(); i>desiredSize; i--) {
// Get the key and invoke the remove method on it.
if (remove(lastAccessedList.getLast().object, true) == null) {
log.warning("Error attempting to cullCache with remove(" + lastAccessedList.getLast().object.toString() + ") - cacheObject not found in cache!");
LOGGER.warning("Error attempting to cullCache with remove(" + lastAccessedList.getLast().object.toString() + ") - cacheObject not found in cache!");
lastAccessedList.getLast().remove();
}
}

View file

@ -55,7 +55,7 @@ import org.xmlpull.v1.XmlPullParserException;
* @author Gaston Dombiak
*/
public class PacketParserUtils {
private static Logger logger = Logger.getLogger(PacketParserUtils.class.getName());
private static final Logger LOGGER = Logger.getLogger(PacketParserUtils.class.getName());
/**
* Namespace used to store packet properties.
@ -197,7 +197,7 @@ public class PacketParserUtils {
type = Presence.Type.valueOf(typeString);
}
catch (IllegalArgumentException iae) {
logger.warning("Found invalid presence type " + typeString);
LOGGER.warning("Found invalid presence type " + typeString);
}
}
Presence presence = new Presence(type);
@ -241,7 +241,7 @@ public class PacketParserUtils {
presence.setMode(Presence.Mode.valueOf(modeText));
}
catch (IllegalArgumentException iae) {
logger.warning("Found invalid presence mode " + modeText);
LOGGER.warning("Found invalid presence mode " + modeText);
}
}
else if (elementName.equals("error")) {
@ -262,7 +262,7 @@ public class PacketParserUtils {
presence.addExtension(PacketParserUtils.parsePacketExtension(elementName, namespace, parser));
}
catch (Exception e) {
logger.warning("Failed to parse extension packet in Presence packet.");
LOGGER.warning("Failed to parse extension packet in Presence packet.");
}
}
}
@ -642,7 +642,7 @@ public class PacketParserUtils {
value = in.readObject();
}
catch (Exception e) {
logger.log(Level.SEVERE, "Error parsing java object", e);
LOGGER.log(Level.SEVERE, "Error parsing java object", e);
}
}
if (name != null && value != null) {
@ -785,7 +785,7 @@ public class PacketParserUtils {
}
}
catch (IllegalArgumentException iae) {
logger.log(Level.SEVERE, "Could not find error type for " + type.toUpperCase(), iae);
LOGGER.log(Level.SEVERE, "Could not find error type for " + type.toUpperCase(), iae);
}
return new XMPPError(Integer.parseInt(errorCode), errorType, condition, message, extensions);
}

View file

@ -40,7 +40,7 @@ import java.util.regex.Pattern;
* A collection of utility methods for String objects.
*/
public class StringUtils {
private static Logger log = Logger.getLogger(StringUtils.class.getName());
private static final Logger LOGGER = Logger.getLogger(StringUtils.class.getName());
/**
* Date format as defined in XEP-0082 - XMPP Date and Time Profiles. The time zone is set to
@ -661,7 +661,7 @@ public class StringUtils {
digest = MessageDigest.getInstance("SHA-1");
}
catch (NoSuchAlgorithmException nsae) {
log.log(Level.SEVERE, "Failed to load the SHA-1 MessageDigest. Smack will be unable to function normally.", nsae);
LOGGER.log(Level.SEVERE, "Failed to load the SHA-1 MessageDigest. Smack will be unable to function normally.", nsae);
}
}
// Now, compute hash.
@ -669,7 +669,7 @@ public class StringUtils {
digest.update(data.getBytes("UTF-8"));
}
catch (UnsupportedEncodingException e) {
log.log(Level.SEVERE, "Error computing hash", e);
LOGGER.log(Level.SEVERE, "Error computing hash", e);
}
return encodeHex(digest.digest());
}