Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc0da4b3

Browse files
committed
Removed sonar issue and converted Audio to eager singleton for simplicity
1 parent9bbb4da commitc0da4b3

File tree

1 file changed

+9
-14
lines changed
  • event-queue/src/main/java/com/iluwatar/event/queue

1 file changed

+9
-14
lines changed

‎event-queue/src/main/java/com/iluwatar/event/queue/Audio.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
packagecom.iluwatar.event.queue;
2525

26+
importorg.slf4j.Logger;
27+
importorg.slf4j.LoggerFactory;
28+
2629
importjava.io.File;
2730
importjava.io.IOException;
2831

@@ -38,6 +41,8 @@
3841
*
3942
*/
4043
publicclassAudio {
44+
privatestaticfinalLoggerLOGGER =LoggerFactory.getLogger(Audio.class);
45+
privatestaticfinalAudioINSTANCE =newAudio();
4146

4247
privatestaticfinalintMAX_PENDING =16;
4348

@@ -55,7 +60,7 @@ public class Audio {
5560
}
5661

5762
publicstaticAudiogetInstance() {
58-
returnSingletonHolder.getAudioInstance();
63+
returnINSTANCE;
5964
}
6065

6166
/**
@@ -141,14 +146,11 @@ private void update() {
141146
clip.open(audioStream);
142147
clip.start();
143148
}catch (LineUnavailableExceptione) {
144-
System.err.println("Error occoured while loading the audio: The line is unavailable");
145-
e.printStackTrace();
149+
LOGGER.trace("Error occoured while loading the audio: The line is unavailable",e);
146150
}catch (IOExceptione) {
147-
System.err.println("Input/Output error while loading the audio");
148-
e.printStackTrace();
151+
LOGGER.trace("Input/Output error while loading the audio",e);
149152
}catch (IllegalArgumentExceptione) {
150-
System.err.println("The system doesn't support the sound: " +e.getMessage());
151-
e.printStackTrace();
153+
LOGGER.trace("The system doesn't support the sound: " +e.getMessage(),e);
152154
}
153155
}
154156

@@ -172,11 +174,4 @@ public PlayMessage[] getPendingAudio() {
172174
returnpendingAudio;
173175
}
174176

175-
privatestaticclassSingletonHolder {
176-
privatestaticfinalAudioINSTANCE =newAudio();
177-
178-
staticAudiogetAudioInstance() {
179-
returnINSTANCE;
180-
}
181-
}
182177
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp