Skip to content

Commit ed3dd35

Browse files
Fix for Client command broken issue #56
Fix issue #56 (logger was null)
1 parent 39e6b01 commit ed3dd35

File tree

22 files changed

+156
-8
lines changed

22 files changed

+156
-8
lines changed

WaarpAdministrator/src/main/java/org/waarp/administrator/AdminGui.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ public void run() {
166166
* Create the application.
167167
*/
168168
public AdminGui() {
169+
if (logger == null) {
170+
logger = WaarpLoggerFactory.getLogger(AdminGui.class);
171+
}
169172
initialize();
170173
}
171174

WaarpCommon/src/main/java/org/waarp/common/filemonitor/FileMonitor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,9 @@ protected static class FileMonitorTimerTask implements TimerTask {
830830
* @param fileMonitor
831831
*/
832832
protected FileMonitorTimerTask(FileMonitor fileMonitor) {
833+
if (logger == null) {
834+
logger = WaarpLoggerFactory.getLogger(FileMonitor.class);
835+
}
833836
this.fileMonitor = fileMonitor;
834837
}
835838

@@ -878,6 +881,9 @@ protected class FileMonitorTimerInformationTask implements TimerTask {
878881
*/
879882
protected FileMonitorTimerInformationTask(
880883
FileMonitorCommandRunnableFuture informationMonitorCommand) {
884+
if (logger == null) {
885+
logger = WaarpLoggerFactory.getLogger(FileMonitor.class);
886+
}
881887
this.informationMonitorCommand = informationMonitorCommand;
882888
}
883889

@@ -1038,6 +1044,9 @@ public FileItem clone() { //NOSONAR
10381044
}
10391045

10401046
public static void main(String[] args) {
1047+
if (logger == null) {
1048+
logger = WaarpLoggerFactory.getLogger(FileMonitor.class);
1049+
}
10411050
if (args.length < 3) {
10421051
SysErrLogger.FAKE_LOGGER
10431052
.syserr("Need a statusfile, a stopfile and a directory to test");

WaarpGatewayKernel/src/main/java/org/waarp/gateway/kernel/rest/client/HttpRestClientHelper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,7 @@ public void closeAll() {
338338
public static void main(String[] args) {
339339
WaarpLoggerFactory
340340
.setDefaultFactoryIfNotSame(new WaarpSlf4JLoggerFactory(null));
341-
final WaarpLogger logger =
342-
WaarpLoggerFactory.getLogger(HttpRestClientHelper.class);
341+
logger = WaarpLoggerFactory.getLogger(HttpRestClientHelper.class);
343342
if (args.length < 5) {
344343
logger.error(
345344
NEED_MORE_ARGUMENTS_HTTP_HOST_PORT_URI_METHOD_USER_SIGN_PATH_NOSIGN_JSON);

WaarpR66/src/main/java/org/waarp/openr66/client/AbstractBusinessRequest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ public static void main(String[] args) {
210210
* @return True if all parameters were found and correct
211211
*/
212212
protected static boolean getParams(String[] args) {
213+
if (logger == null) {
214+
logger = WaarpLoggerFactory.getLogger(AbstractBusinessRequest.class);
215+
}
213216
if (args.length < 3) {
214217
logger.error(_INFO_ARGS);
215218
return false;

WaarpR66/src/main/java/org/waarp/openr66/client/AbstractTransfer.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ public static boolean sendValidPacket(DbHostAuth host,
142142
LocalChannelReference localChannelReference,
143143
AbstractLocalPacket packet,
144144
final R66Future future) {
145+
if (logger == null) {
146+
logger = WaarpLoggerFactory.getLogger(AbstractTransfer.class);
147+
}
145148
try {
146149
ChannelUtils
147150
.writeAbstractLocalPacket(localChannelReference, packet, false);
@@ -295,6 +298,9 @@ protected static void clear() {
295298
* @return True if all parameters were found and correct
296299
*/
297300
protected static boolean getParams(String[] args, boolean submitOnly) {
301+
if (logger == null) {
302+
logger = WaarpLoggerFactory.getLogger(AbstractTransfer.class);
303+
}
298304
if (args.length < 2) {
299305
logger.error(_INFO_ARGS);
300306
return false;
@@ -485,6 +491,9 @@ public List<String> getLocalFiles(DbRule dbrule, String[] localfilenames) {
485491
public static LocalChannelReference tryConnect(DbHostAuth host,
486492
R66Future future,
487493
NetworkTransaction networkTransaction) {
494+
if (logger == null) {
495+
logger = WaarpLoggerFactory.getLogger(AbstractTransfer.class);
496+
}
488497
logger.info("Try RequestTransfer to " + host);
489498
SocketAddress socketAddress;
490499
try {
@@ -516,6 +525,9 @@ public static LocalChannelReference tryConnect(DbHostAuth host,
516525
protected static void prepareKoOutputFormat(final R66Future future,
517526
final R66Result result,
518527
final OutputFormat outputFormat) {
528+
if (logger == null) {
529+
logger = WaarpLoggerFactory.getLogger(AbstractTransfer.class);
530+
}
519531
partialOutputFormat(result.getRunner(), outputFormat);
520532
if (result.getRunner().getErrorInfo() == ErrorCode.Warning) {
521533
outputFormat.setValue(FIELDS.status.name(), 1);
@@ -543,6 +555,9 @@ protected static void prepareKoOutputFormat(final R66Future future,
543555

544556
protected static void prepareKoOutputFormat(final R66Future future,
545557
final OutputFormat outputFormat) {
558+
if (logger == null) {
559+
logger = WaarpLoggerFactory.getLogger(AbstractTransfer.class);
560+
}
546561
outputFormat.setValue(FIELDS.status.name(), 2);
547562
outputFormat.setValue(FIELDS.statusTxt.name(), Messages
548563
.getString("Transfer.FailedNoId")); //$NON-NLS-1$
@@ -554,6 +569,9 @@ protected static void prepareKoOutputFormat(final R66Future future,
554569
protected static void prepareOkOutputFormat(final long delay,
555570
final R66Result result,
556571
final OutputFormat outputFormat) {
572+
if (logger == null) {
573+
logger = WaarpLoggerFactory.getLogger(AbstractTransfer.class);
574+
}
557575
if (result.getRunner().getErrorInfo() == ErrorCode.Warning) {
558576
outputFormat.setValue(FIELDS.status.name(), 1);
559577
outputFormat.setValue(FIELDS.statusTxt.name(),
@@ -575,6 +593,9 @@ protected static void prepareOkOutputFormat(final long delay,
575593

576594
private static void partialOutputFormat(final DbTaskRunner runner,
577595
final OutputFormat outputFormat) {
596+
if (logger == null) {
597+
logger = WaarpLoggerFactory.getLogger(AbstractTransfer.class);
598+
}
578599
outputFormat.setValue(FIELDS.remote.name(), rhost);
579600
outputFormat.setValue(FIELDS.ruleid.name(), runner.getRuleId());
580601
outputFormat.setValueString(runner.getJson());
@@ -594,6 +615,9 @@ private static void partialOutputFormat(final DbTaskRunner runner,
594615
protected static void prepareSubmitKoOutputFormat(final R66Future future,
595616
final DbTaskRunner runner,
596617
final OutputFormat outputFormat) {
618+
if (logger == null) {
619+
logger = WaarpLoggerFactory.getLogger(AbstractTransfer.class);
620+
}
597621
outputFormat.setValue(FIELDS.status.name(), 2);
598622
if (runner == null) {
599623
outputFormat.setValue(FIELDS.statusTxt.name(),
@@ -617,6 +641,9 @@ protected static void prepareSubmitKoOutputFormat(final R66Future future,
617641

618642
protected static void prepareSubmitOkOutputFormat(final DbTaskRunner runner,
619643
final OutputFormat outputFormat) {
644+
if (logger == null) {
645+
logger = WaarpLoggerFactory.getLogger(AbstractTransfer.class);
646+
}
620647
outputFormat.setValue(FIELDS.status.name(), 0);
621648
outputFormat.setValue(FIELDS.statusTxt.name(),
622649
Messages.getString("SubmitTransfer.3") + Messages

WaarpR66/src/main/java/org/waarp/openr66/client/Message.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ public class Message implements Runnable {
7878
* @return True if all parameters were found and correct
7979
*/
8080
protected static boolean getParams(String[] args) {
81+
if (logger == null) {
82+
logger = WaarpLoggerFactory.getLogger(Message.class);
83+
}
8184
_infoArgs = Messages.getString("Message.0") +
8285
Messages.getString("Message.OutputFormat"); //$NON-NLS-1$
8386
if (args.length < 5) {

WaarpR66/src/main/java/org/waarp/openr66/client/MultipleDirectTransfer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public MultipleDirectTransfer(R66Future future, String remoteHost,
7474

7575
@Override
7676
public void run() {
77+
if (logger == null) {
78+
logger = WaarpLoggerFactory.getLogger(MultipleDirectTransfer.class);
79+
}
7780
final String[] localfilenames = transferArgs.getFilename().split(",");
7881
final String[] rhosts = transferArgs.getRemoteHost().split(",");
7982
boolean inError = false;

WaarpR66/src/main/java/org/waarp/openr66/client/RequestInformation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ public RequestInformation(R66Future future, String requested, String rulename,
176176
this.id = id;
177177
this.isTo = isTo;
178178
this.networkTransaction = networkTransaction;
179+
if (logger == null) {
180+
logger = WaarpLoggerFactory.getLogger(RequestInformation.class);
181+
}
179182
}
180183

181184
@Override
182185
public void run() {
183-
if (logger == null) {
184-
logger = WaarpLoggerFactory.getLogger(RequestInformation.class);
185-
}
186186
InformationPacket request;
187187
if (code != REQUEST_CHECK) {
188188
request = new InformationPacket(rulename, code, filename);

WaarpR66/src/main/java/org/waarp/openr66/client/RequestTransfer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ public class RequestTransfer implements Runnable {
104104
* @return True if all parameters were found and correct
105105
*/
106106
protected static boolean getParams(String[] args) {
107+
if (logger == null) {
108+
logger = WaarpLoggerFactory.getLogger(RequestTransfer.class);
109+
}
107110
_infoArgs = Messages.getString("RequestTransfer.0") +
108111
Messages.getString("Message.OutputFormat"); //$NON-NLS-1$
109112
if (args.length < 5) {
@@ -238,6 +241,9 @@ public RequestTransfer(R66Future future, long specialId, String requested,
238241
this.restart = restart;
239242
this.restarttime = restarttime;
240243
this.networkTransaction = networkTransaction;
244+
if (logger == null) {
245+
logger = WaarpLoggerFactory.getLogger(RequestTransfer.class);
246+
}
241247
}
242248

243249
@Override

WaarpR66/src/main/java/org/waarp/openr66/client/SpooledDirectoryTransfer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ public class SpooledRunner extends FileMonitorCommandRunnableFuture {
452452

453453
public SpooledRunner(FileItem fileItem) {
454454
super(fileItem);
455+
if (logger == null) {
456+
logger = WaarpLoggerFactory.getLogger(SpooledDirectoryTransfer.class);
457+
}
455458
}
456459

457460
@Override
@@ -949,6 +952,9 @@ public void setIgnoreAlreadyUsed(final boolean ignoreAlreadyUsed) {
949952

950953
@SuppressWarnings("unchecked")
951954
protected static boolean getParamsFromConfigFile(String filename) {
955+
if (logger == null) {
956+
logger = WaarpLoggerFactory.getLogger(SpooledDirectoryTransfer.class);
957+
}
952958
Document document;
953959
// Open config file
954960
try {
@@ -1110,6 +1116,9 @@ protected static boolean getParamsFromConfigFile(String filename) {
11101116
* @return True if all parameters were found and correct
11111117
*/
11121118
protected static boolean getParams(String[] args) {
1119+
if (logger == null) {
1120+
logger = WaarpLoggerFactory.getLogger(SpooledDirectoryTransfer.class);
1121+
}
11131122
_infoArgs = Messages.getString("SpooledDirectoryTransfer.0"); //$NON-NLS-1$
11141123
if (args.length < 1) {
11151124
logger.error(_infoArgs);

0 commit comments

Comments
 (0)