Skip to content

Commit

Permalink
Cleanup - squid:S1312 - Loggers should be "private static final" and …
Browse files Browse the repository at this point in the history
…should share a naming convention
  • Loading branch information
Mohamed Ezzat committed Jun 30, 2016
1 parent 7327744 commit 715d517
Show file tree
Hide file tree
Showing 41 changed files with 178 additions and 178 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

public class JettyCommandService extends AbstractHandler
{
private static Logger logger = Logger.getLogger(JettyCommandService.class.getName());
private static final Logger LOGGER = Logger.getLogger(JettyCommandService.class.getName());

private static Map<String, Device> deviceMap = new HashMap<>();

Expand Down Expand Up @@ -87,7 +87,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
}
catch(RuntimeException e)
{
logger.log(Level.SEVERE, e.getMessage(), e);
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
}
Expand Down Expand Up @@ -126,7 +126,7 @@ private void handleCommandRequest(Request baseRequest, HttpServletRequest reques
Device device = deviceMap.get(deviceId);
if(device == null)
{
logger.log(Level.SEVERE, "Device ID is not valid: " + deviceId);
LOGGER.log(Level.SEVERE, "Device ID is not valid: " + deviceId);
sendErrorResponse(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Device ID is not valid: " + deviceId, baseRequest, response);
}
else
Expand Down Expand Up @@ -186,7 +186,7 @@ private void handleCommandRequest(Request baseRequest, HttpServletRequest reques
}
else
{
logger.log(Level.INFO, "Error response: code=" + deviceResponse.getResponseCode() + " message=" + deviceResponse.getResponseMessage());
LOGGER.log(Level.INFO, "Error response: code=" + deviceResponse.getResponseCode() + " message=" + deviceResponse.getResponseMessage());
sendErrorResponse(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, deviceResponse.getResponseMessage(), baseRequest, response);
}
}
Expand All @@ -203,7 +203,7 @@ private void handleCommandRequest(Request baseRequest, HttpServletRequest reques
}
catch(NumberFormatException e)
{
logger.log(Level.INFO, "Could not parse rate parameter: " + request.getParameter("r"));
LOGGER.log(Level.INFO, "Could not parse rate parameter: " + request.getParameter("r"));
sendErrorResponse(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Rate is not valid.", baseRequest, response);
}

Expand Down Expand Up @@ -238,7 +238,7 @@ private void handleCommandRequest(Request baseRequest, HttpServletRequest reques
}
catch(NumberFormatException e)
{
logger.log(Level.INFO, "Could not parse position parameter: " + request.getParameter("p"));
LOGGER.log(Level.INFO, "Could not parse position parameter: " + request.getParameter("p"));
sendErrorResponse(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Position is not valid.", baseRequest, response);
}

Expand All @@ -261,15 +261,15 @@ private void handleCommandRequest(Request baseRequest, HttpServletRequest reques
}
else
{
logger.log(Level.INFO, "Error response: code=" + deviceResponse.getResponseCode() + " message=" + deviceResponse.getResponseMessage());
LOGGER.log(Level.INFO, "Error response: code=" + deviceResponse.getResponseCode() + " message=" + deviceResponse.getResponseMessage());
sendErrorResponse(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, deviceResponse.getResponseMessage(), baseRequest, response);
}
}
}
break;
default:
{
logger.info("Command not understood: " + request.getParameter("t"));
LOGGER.info("Command not understood: " + request.getParameter("t"));
sendErrorResponse(HttpServletResponse.SC_NOT_ACCEPTABLE, "Command not understood.", baseRequest, response);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@Singleton
public class RemoteSpeakerDiscoverer implements IDiscoverer
{
public static final Logger logger = LoggerFactory.getLogger(RemoteSpeakerDiscoverer.class);
private static final Logger LOGGER = LoggerFactory.getLogger(RemoteSpeakerDiscoverer.class);

private final JmmDNS mDNS;
private final Map<JmDNS, InetAddress> interfaces = new HashMap<JmDNS, InetAddress>();
Expand All @@ -48,21 +48,21 @@ public RemoteSpeakerDiscoverer(JmmDNS mDNS, ISpeakerListener speakerListener)
@Override
public void serviceAdded(ServiceEvent event)
{
logger.info("ADD: " + event.getDNS().getServiceInfo(event.getType(), event.getName()));
LOGGER.info("ADD: " + event.getDNS().getServiceInfo(event.getType(), event.getName()));
}

@Override
public void serviceRemoved(ServiceEvent event)
{
logger.debug("REMOVE: " + event.getName());
LOGGER.debug("REMOVE: " + event.getName());
this.speakerListener.removeAvailableSpeaker(event.getInfo().getServer(), event.getInfo().getPort());
}

@SuppressWarnings("deprecation")
@Override
public void serviceResolved(ServiceEvent event)
{
logger.info("ADD: " + event.getDNS().getServiceInfo(event.getType(), event.getName()));
LOGGER.info("ADD: " + event.getDNS().getServiceInfo(event.getType(), event.getName()));
speakerListener.registerAvailableSpeaker(DeviceConnectionService.getConnection(new Device(event.getName(), event.getInfo().getInetAddress(), event.getInfo().getPort())));
}

Expand All @@ -71,7 +71,7 @@ public void inetAddressAdded(NetworkTopologyEvent event)
{
JmDNS mdns = event.getDNS();
InetAddress address = event.getInetAddress();
logger.info("Registered RemoteSpeakerDiscoverer @ " + address.getHostAddress());
LOGGER.info("Registered RemoteSpeakerDiscoverer @ " + address.getHostAddress());
mdns.addServiceListener(ISpeakerListener.RAOP_TYPE, this);
interfaces.put(mdns, address);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

public abstract class DeviceCommand
{
private static Logger logger = Logger.getLogger(DeviceCommand.class.getName());
private static final Logger LOGGER = Logger.getLogger(DeviceCommand.class.getName());

private final Map<String, String> parameterMap = new HashMap<>();

Expand All @@ -38,7 +38,7 @@ protected String constructCommand(String commandName, String content)
}
catch(UnsupportedEncodingException e)
{
logger.log(Level.SEVERE, e.getMessage(), e);
LOGGER.log(Level.SEVERE, e.getMessage(), e);
throw new RuntimeException(e.getMessage(), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
public class DeviceConnection
{
private static Logger logger = Logger.getLogger(DeviceConnection.class.getName());
private static final Logger LOGGER = Logger.getLogger(DeviceConnection.class.getName());

private final Device device;
private Socket socket;
Expand Down Expand Up @@ -49,7 +49,7 @@ public DeviceResponse sendCommand(DeviceCommand command)
}
catch(IOException e)
{
logger.log(Level.SEVERE, e.getMessage(), e);
LOGGER.log(Level.SEVERE, e.getMessage(), e);
throw new RuntimeException(e.getMessage(), e);
}
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public DeviceResponse sendCommand(DeviceCommand command)
}
catch(IOException e)
{
logger.log(Level.SEVERE, e.getMessage(), e);
LOGGER.log(Level.SEVERE, e.getMessage(), e);
throw new RuntimeException(e.getMessage(), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

public final class AirTunesCrytography
{
private static final Logger s_logger = Logger.getLogger(AirTunesCrytography.class.getName());
private static final Logger LOGGER = Logger.getLogger(AirTunesCrytography.class.getName());

/**
* The JCA/JCE Provider who supplies the necessary cryptographic algorithms
Expand Down Expand Up @@ -132,7 +132,7 @@ else if(resolveProperty(Provider, "Cipher", algorithm) != null)

/* Create a {@link javax.crypto.Cipher} instance from the {@link javax.crypto.CipherSpi} the provider gave us */

s_logger.info("Using SPI " + cipherSpi.getClass() + " for " + transformation);
LOGGER.info("Using SPI " + cipherSpi.getClass() + " for " + transformation);
return getCipher(cipherSpi, transformation.toUpperCase());
}
catch(final RuntimeException e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class AudioOutputQueue implements AudioClock
{
private static Logger s_logger = Logger.getLogger(AudioOutputQueue.class.getName());
private static final Logger LOGGER = Logger.getLogger(AudioOutputQueue.class.getName());

private static final double QueueLengthMaxSeconds = 10;
private static final double BufferSizeSeconds = 0.05;
Expand Down Expand Up @@ -151,7 +151,7 @@ public void run()
if(gapFrames < -m_packetSizeFrames)
{
/* Too late for playback */
s_logger.warning("Audio data was scheduled for playback " + (-gapFrames) + " frames ago, skipping");
LOGGER.warning("Audio data was scheduled for playback " + (-gapFrames) + " frames ago, skipping");

m_queue.remove(entryFrameTime);
continue;
Expand All @@ -164,7 +164,7 @@ else if(gapFrames < m_packetSizeFrames)
/* Unmute line in case it was muted previously */
if(lineMuted)
{
s_logger.info("Audio data available, un-muting line");
LOGGER.info("Audio data available, un-muting line");

lineMuted = false;
applyGain();
Expand All @@ -179,13 +179,13 @@ else if(getLineGain() != m_requestedGain)
int nextPlaybackSamplesLength = nextPlaybackSamples.length;
if(nextPlaybackSamplesLength % m_bytesPerFrame != 0)
{
s_logger.severe("Audio data contains non-integral number of frames, ignore last " + (nextPlaybackSamplesLength % m_bytesPerFrame) + " bytes");
LOGGER.severe("Audio data contains non-integral number of frames, ignore last " + (nextPlaybackSamplesLength % m_bytesPerFrame) + " bytes");

nextPlaybackSamplesLength -= nextPlaybackSamplesLength % m_bytesPerFrame;
}

/* Append packet to line */
s_logger.finest("Audio data containing " + nextPlaybackSamplesLength / m_bytesPerFrame + " frames for playback time " + entryFrameTime + " found in queue, appending to the output line");
LOGGER.finest("Audio data containing " + nextPlaybackSamplesLength / m_bytesPerFrame + " frames for playback time " + entryFrameTime + " found in queue, appending to the output line");
appendFrames(nextPlaybackSamples, 0, nextPlaybackSamplesLength, entryLineTime);
continue;
}
Expand All @@ -196,7 +196,7 @@ else if(getLineGain() != m_requestedGain)
if(!didWarnGap)
{
didWarnGap = true;
s_logger.warning("Audio data missing for frame time " + getNextLineTime() + " (currently " + gapFrames + " frames), writing " + m_packetSizeFrames + " frames of silence");
LOGGER.warning("Audio data missing for frame time " + getNextLineTime() + " (currently " + gapFrames + " frames), writing " + m_packetSizeFrames + " frames of silence");
}
}
}
Expand All @@ -208,7 +208,7 @@ else if(getLineGain() != m_requestedGain)
{
lineMuted = true;
setLineGain(Float.NEGATIVE_INFINITY);
s_logger.fine("Audio data ended at frame time " + getNextLineTime() + ", writing " + m_packetSizeFrames + " frames of silence and muted line");
LOGGER.fine("Audio data ended at frame time " + getNextLineTime() + ", writing " + m_packetSizeFrames + " frames of silence and muted line");
}
}

Expand All @@ -222,7 +222,7 @@ else if(getLineGain() != m_requestedGain)
}
catch(final Throwable e)
{
s_logger.log(Level.SEVERE, "Audio output thread died unexpectedly", e);
LOGGER.log(Level.SEVERE, "Audio output thread died unexpectedly", e);
}
finally
{
Expand Down Expand Up @@ -269,7 +269,7 @@ private void appendFrames(final byte[] samples, int off, final int len, long lin
else if(timingErrorFrames > 0)
{
/* Samples to append scheduled after the line end. Fill the gap with silence */
s_logger.warning("Audio output non-continous (gap of " + timingErrorFrames + " frames), filling with silence");
LOGGER.warning("Audio output non-continous (gap of " + timingErrorFrames + " frames), filling with silence");

appendSilence((int) (lineTime - endLineTime));
}
Expand All @@ -278,7 +278,7 @@ else if(timingErrorFrames < 0)
/*
* Samples to append scheduled before the line end. Remove the overlapping part and retry
*/
s_logger.warning("Audio output non-continous (overlap of " + (-timingErrorFrames) + "), skipping overlapping frames");
LOGGER.warning("Audio output non-continous (overlap of " + (-timingErrorFrames) + "), skipping overlapping frames");

off += (endLineTime - lineTime) * m_bytesPerFrame;
lineTime += endLineTime - lineTime;
Expand Down Expand Up @@ -334,7 +334,7 @@ private void appendFrames(final byte[] samples, int off, int len)
/* Write samples to line */
final int bytesWritten = m_line.write(samplesConverted, 0, samplesConverted.length);
if(bytesWritten != len)
s_logger.warning("Audio output line accepted only " + bytesWritten + " bytes of sample data while trying to write " + samples.length + " bytes");
LOGGER.warning("Audio output line accepted only " + bytesWritten + " bytes of sample data while trying to write " + samples.length + " bytes");

/* Update state */
synchronized(AudioOutputQueue.this)
Expand All @@ -343,7 +343,7 @@ private void appendFrames(final byte[] samples, int off, int len)
for(int b = 0; b < m_bytesPerFrame; ++b)
m_lineLastFrame[b] = samples[off + len - (m_bytesPerFrame - b)];

s_logger.finest("Audio output line end is now at " + getNextLineTime() + " after writing " + len / m_bytesPerFrame + " frames");
LOGGER.finest("Audio output line end is now at " + getNextLineTime() + " after writing " + len / m_bytesPerFrame + " frames");
}
}

Expand All @@ -358,7 +358,7 @@ private float getLineGain()
final FloatControl gainControl = (FloatControl) m_line.getControl(FloatControl.Type.MASTER_GAIN);
return gainControl.getValue();
}
s_logger.severe("Audio output line doesn not support volume control");
LOGGER.severe("Audio output line doesn not support volume control");
return 0.0f;
}

Expand Down Expand Up @@ -387,7 +387,7 @@ else if(gain > gainControl.getMaximum())
gainControl.setValue(gain);
}
else
s_logger.severe("Audio output line doesn not support volume control");
LOGGER.severe("Audio output line doesn not support volume control");
}

}
Expand Down Expand Up @@ -426,7 +426,7 @@ else if(AudioFormat.Encoding.PCM_UNSIGNED.equals(audioFormat.getEncoding()))
final DataLine.Info lineInfo = new DataLine.Info(SourceDataLine.class, m_format, desiredBufferSize);
m_line = (SourceDataLine) AudioSystem.getLine(lineInfo);
m_line.open(m_format, desiredBufferSize);
s_logger.info("Audio output line created and openend. Requested buffer of " + desiredBufferSize / m_bytesPerFrame + " frames, got " + m_line.getBufferSize() / m_bytesPerFrame + " frames");
LOGGER.info("Audio output line created and openend. Requested buffer of " + desiredBufferSize / m_bytesPerFrame + " frames, got " + m_line.getBufferSize() / m_bytesPerFrame + " frames");

/*
* Start enqueuer thread and wait for the line to start. The wait guarantees that the AudioClock functions return sensible values right after construction
Expand Down Expand Up @@ -497,15 +497,15 @@ public synchronized boolean enqueue(final long frameTime, final byte[] frames)
if(delay < -packetSeconds)
{
/* The whole packet is scheduled to be played in the past */
s_logger.warning("Audio data arrived " + -(delay) + " seconds too late, dropping");
LOGGER.warning("Audio data arrived " + -(delay) + " seconds too late, dropping");
return false;
}
else if(delay > QueueLengthMaxSeconds)
{
/*
* The packet extends further into the future that our maximum queue size. We reject it, since this is probably the result of some timing discrepancies
*/
s_logger.warning("Audio data arrived " + delay + " seconds too early, dropping");
LOGGER.warning("Audio data arrived " + delay + " seconds too early, dropping");
return false;
}

Expand All @@ -530,7 +530,7 @@ public synchronized void setFrameTime(final long frameTime, final double seconds
final long frameTimeOffsetPrevious = m_frameTimeOffset;
m_frameTimeOffset = frameTime - lineTime;

s_logger.fine("Frame time adjusted by " + (m_frameTimeOffset - frameTimeOffsetPrevious) + " based on timing information " + ageSeconds + " seconds old and " + (m_latestSeenFrameTime - frameTime) + " frames before latest seen frame time");
LOGGER.fine("Frame time adjusted by " + (m_frameTimeOffset - frameTimeOffsetPrevious) + " based on timing information " + ageSeconds + " seconds old and " + (m_latestSeenFrameTime - frameTime) + " frames before latest seen frame time");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
*/
public class ExceptionLoggingHandler extends SimpleChannelHandler
{
private static Logger s_logger = Logger.getLogger(ExceptionLoggingHandler.class.getName());
private static final Logger LOGGER = Logger.getLogger(ExceptionLoggingHandler.class.getName());

@Override
public void exceptionCaught(final ChannelHandlerContext ctx, final ExceptionEvent evt) throws Exception
{
super.exceptionCaught(ctx, evt);
s_logger.log(Level.WARNING, "Handler raised exception", evt.getCause());
LOGGER.log(Level.WARNING, "Handler raised exception", evt.getCause());
}
}
Loading

0 comments on commit 715d517

Please sign in to comment.