From 08407eef25bd02c08098c3bb9751d8e0a9752746 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sat, 2 Oct 2021 11:09:09 +0400 Subject: [PATCH] Dev: migrated to single logger lib (replaced slf4j usage by log4j), clean up and documented pom files, updated some libs; --- Mage.Client/pom.xml | 122 ++++++++++-------- .../java/mage/client/util/audio/LinePool.java | 31 ++--- Mage.Common/pom.xml | 2 - Mage.Server.Console/pom.xml | 1 - Mage.Server/pom.xml | 11 +- .../main/java/mage/server/MageServerImpl.java | 4 +- Mage.Sets/pom.xml | 1 - Mage.Tests/pom.xml | 1 - Mage.Verify/pom.xml | 1 - pom.xml | 61 +++++---- 10 files changed, 125 insertions(+), 110 deletions(-) diff --git a/Mage.Client/pom.xml b/Mage.Client/pom.xml index 57b9da979ed..18d54f76a7a 100644 --- a/Mage.Client/pom.xml +++ b/Mage.Client/pom.xml @@ -14,7 +14,6 @@ Mage Client - org.mage mage @@ -31,89 +30,105 @@ ${project.version} - com.googlecode.jspf - jspf-core - 0.9.1 + ${project.groupId} + mage-counter-plugin + 0.1 + runtime + + + + com.google.guava + guava log4j log4j - - org.slf4j - slf4j-log4j12 - net.java.truevfs truevfs-profile-base + + junit + junit + + + org.unbescape + unbescape + - + net.sf.trove4j trove4j 3.0.3 + + com.googlecode.jspf + jspf-core + 0.9.1 + + + + + com.mortennobel java-image-scaling 0.8.6 - com.google.guava - guava - - + + org.swinglabs swingx 1.6.1 - org.jetlang - jetlang - 0.2.23 - - - com.amazonaws - aws-java-sdk-s3 - 1.11.827 - - - com.jgoodies - forms - 1.2.1 - - - com.intellij - forms_rt - 7.0.3 - - - junit - junit - test - - - ${project.groupId} - mage-counter-plugin - 0.1 - runtime - - - org.jdesktop - beansbinding - 1.2.1 - - + org.swinglabs swing-layout 1.0.3 + + org.jetlang + jetlang + 0.2.23 + + + + + com.amazonaws + aws-java-sdk-s3 + 1.12.78 + + + + + com.jgoodies + forms + 1.2.1 + + + + com.intellij + forms_rt + 7.0.3 + + + + + org.jdesktop + beansbinding + 1.2.1 + + + org.jsoup jsoup - 1.14.2 + 1.14.3 @@ -135,6 +150,7 @@ + net.java.balloontip balloontip 1.2.4.1 @@ -153,15 +169,11 @@ + org.ocpsoft.prettytime prettytime 4.0.6.Final - - org.unbescape - unbescape - 1.1.6.RELEASE - diff --git a/Mage.Client/src/main/java/mage/client/util/audio/LinePool.java b/Mage.Client/src/main/java/mage/client/util/audio/LinePool.java index 633b677a350..cab0b04e7da 100644 --- a/Mage.Client/src/main/java/mage/client/util/audio/LinePool.java +++ b/Mage.Client/src/main/java/mage/client/util/audio/LinePool.java @@ -16,14 +16,13 @@ import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.Mixer; import javax.sound.sampled.SourceDataLine; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import mage.utils.ThreadUtils; public class LinePool { - private final Logger log = LoggerFactory.getLogger(getClass()); + private final org.apache.log4j.Logger logger = Logger.getLogger(LinePool.class); private static final int LINE_CLEANUP_INTERVAL = 30000; private final Queue freeLines = new ArrayDeque<>(); @@ -55,7 +54,7 @@ public class LinePool { SourceDataLine line = (SourceDataLine) mixer.getLine(lineInfo); freeLines.add(line); } catch (LineUnavailableException e) { - log.warn("Failed to get line from mixer", e); + logger.warn("Failed to get line from mixer", e); } } new Timer("Line cleanup", true).scheduleAtFixedRate(new TimerTask() { @@ -65,7 +64,7 @@ public class LinePool { for (SourceDataLine sourceDataLine : freeLines) { if (sourceDataLine.isOpen()) { sourceDataLine.close(); - log.debug("Closed line {}", sourceDataLine); + logger.debug("Closed line " + sourceDataLine); } } } @@ -96,13 +95,13 @@ public class LinePool { public void playSound(final MageClip mageClip) { final SourceDataLine line; synchronized (LinePool.this) { - log.debug("Playing {}", mageClip.getFilename()); + logger.debug("Playing: " + mageClip.getFilename()); logLineStats(); line = borrowLine(); if (line == null) { // no lines available, queue sound to play it when a line is available queue.add(mageClip); - log.debug("Sound {} queued.", mageClip.getFilename()); + logger.debug("Sound queued: " + mageClip.getFilename()); return; } logLineStats(); @@ -113,19 +112,19 @@ public class LinePool { if (!line.isOpen()) { line.open(); line.addLineListener(event -> { - log.debug("Event: {}", event); + logger.debug("Event: " + event); if (event.getType() != Type.STOP) { return; } synchronized (LinePool.this) { - log.debug("Before stop on line {}", line); + logger.debug("Before stop on line " + line); logLineStats(); returnLine(line); - log.debug("After stop on line {}", line); + logger.debug("After stop on line " + line); logLineStats(); MageClip queuedSound = queue.poll(); if (queuedSound != null) { - log.debug("Playing queued sound {}", queuedSound); + logger.debug("Playing queued sound " + queuedSound); playSound(queuedSound); } } @@ -133,19 +132,21 @@ public class LinePool { } line.start(); } catch (LineUnavailableException e) { - log.warn("Failed to open line", e); + logger.warn("Failed to open line", e); } } byte[] buffer = mageClip.getBuffer(); - log.debug("Before write to line {}", line); + logger.debug("Before write to line " + line); line.write(buffer, 0, buffer.length); line.drain(); line.stop(); - log.debug("Line completed: {}", line); + logger.debug("Line completed: " + line); }); } private void logLineStats() { - log.debug("Free lines: {} Active: {} Busy: {}", freeLines.size(), activeLines.size(), busyLines.size()); + logger.debug(String.format("Free lines: %d; Active: %d; Busy: %d", + freeLines.size(), activeLines.size(), busyLines.size() + )); } } diff --git a/Mage.Common/pom.xml b/Mage.Common/pom.xml index 4173847a931..9f5ccb0e013 100644 --- a/Mage.Common/pom.xml +++ b/Mage.Common/pom.xml @@ -63,12 +63,10 @@ org.junit.jupiter junit-jupiter - test org.assertj assertj-core - test org.apache.commons diff --git a/Mage.Server.Console/pom.xml b/Mage.Server.Console/pom.xml index dfe03c7fe4b..044320253bf 100644 --- a/Mage.Server.Console/pom.xml +++ b/Mage.Server.Console/pom.xml @@ -27,7 +27,6 @@ junit junit - test diff --git a/Mage.Server/pom.xml b/Mage.Server/pom.xml index 74d8ac03c9e..7b4df3812d7 100644 --- a/Mage.Server/pom.xml +++ b/Mage.Server/pom.xml @@ -37,7 +37,6 @@ junit junit - test com.sun.xml.bind @@ -54,10 +53,6 @@ log4j log4j - - org.slf4j - slf4j-log4j12 - ${project.groupId} mage-player-ai @@ -284,12 +279,14 @@ org.junit.jupiter junit-jupiter - test org.assertj assertj-core - test + + + org.unbescape + unbescape diff --git a/Mage.Server/src/main/java/mage/server/MageServerImpl.java b/Mage.Server/src/main/java/mage/server/MageServerImpl.java index 6fa1a21a887..19608585bed 100644 --- a/Mage.Server/src/main/java/mage/server/MageServerImpl.java +++ b/Mage.Server/src/main/java/mage/server/MageServerImpl.java @@ -34,8 +34,8 @@ import mage.server.util.SystemUtil; import mage.utils.*; import mage.view.*; import mage.view.ChatMessage.MessageColor; -import org.apache.commons.lang3.StringEscapeUtils; import org.apache.log4j.Logger; +import org.unbescape.html.HtmlEscape; import javax.management.timer.Timer; import java.security.SecureRandom; @@ -489,7 +489,7 @@ public class MageServerImpl implements MageServer { public void sendChatMessage(final UUID chatId, final String userName, final String message) throws MageException { try { callExecutor.execute( - () -> managerFactory.chatManager().broadcast(chatId, userName, StringEscapeUtils.escapeHtml4(message), MessageColor.BLUE, true, null, ChatMessage.MessageType.TALK, null) + () -> managerFactory.chatManager().broadcast(chatId, userName, HtmlEscape.escapeHtml4(message), MessageColor.BLUE, true, null, ChatMessage.MessageType.TALK, null) ); } catch (Exception ex) { handleException(ex); diff --git a/Mage.Sets/pom.xml b/Mage.Sets/pom.xml index ad724706d41..8982ad941e6 100644 --- a/Mage.Sets/pom.xml +++ b/Mage.Sets/pom.xml @@ -29,7 +29,6 @@ junit junit - test diff --git a/Mage.Tests/pom.xml b/Mage.Tests/pom.xml index f9489fd45aa..3c9caf101ec 100644 --- a/Mage.Tests/pom.xml +++ b/Mage.Tests/pom.xml @@ -50,7 +50,6 @@ junit junit - test log4j diff --git a/Mage.Verify/pom.xml b/Mage.Verify/pom.xml index 5f2e558c01d..e27a1031c20 100644 --- a/Mage.Verify/pom.xml +++ b/Mage.Verify/pom.xml @@ -37,7 +37,6 @@ junit junit - test com.fasterxml.jackson.core diff --git a/pom.xml b/pom.xml index 7d1aab37be8..e3828019024 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.5.1 + 3.8.1 1.8 1.8 @@ -157,23 +157,14 @@ + - junit - junit - 4.13.1 - test - - + log4j log4j 1.2.17 - - org.slf4j - slf4j-log4j12 - 1.8.0-beta2 - com.google.code.gson @@ -181,24 +172,16 @@ 2.8.8 + com.google.guava guava 30.1.1-jre - org.junit.jupiter - junit-jupiter - 5.8.1 - - - org.assertj - assertj-core - 3.18.0 - - - org.apache.commons - commons-lang3 - 3.11 + + org.unbescape + unbescape + 1.1.6.RELEASE @@ -206,6 +189,34 @@ truevfs-profile-base 0.14.0 + + + org.apache.commons + commons-lang3 + 3.12.0 + + + + + junit + junit + 4.13.1 + test + + + + org.junit.jupiter + junit-jupiter + 5.8.1 + test + + + + org.assertj + assertj-core + 3.19.0 + test +