26
26
import java .nio .file .Files ;
27
27
import java .nio .file .Path ;
28
28
import java .nio .file .StandardOpenOption ;
29
+ import java .security .AccessController ;
30
+ import java .security .PrivilegedAction ;
29
31
import java .text .SimpleDateFormat ;
30
32
import java .util .Calendar ;
31
33
import java .util .Date ;
@@ -52,6 +54,8 @@ public class DefaultAccessLogReceiver implements AccessLogReceiver, Runnable, Cl
52
54
private static final String DEFAULT_LOG_SUFFIX = "log" ;
53
55
private static final int DEFAULT_RETRY_COUNT = 150 ;
54
56
private static final int DEFAULT_RETRY_DELAY = 200 ;
57
+ public static final String DEFAULT_RETRY_COUNT_PROPERTY = "io.undertow.accesslog.logreceiver.retryCount" ;
58
+ public static final String DEFAULT_RETRY_DELAY_PROPERTY = "io.undertow.accesslog.logreceiver.retryDelay" ;
55
59
56
60
private final Executor logWriteExecutor ;
57
61
@@ -82,8 +86,8 @@ public class DefaultAccessLogReceiver implements AccessLogReceiver, Runnable, Cl
82
86
private boolean initialRun = true ;
83
87
private final boolean rotate ;
84
88
private final LogFileHeaderGenerator fileHeaderGenerator ;
85
- private final int closeRetryCount = DEFAULT_RETRY_COUNT ;
86
- private final int closeRetryDelay = DEFAULT_RETRY_DELAY ;
89
+ private final int closeRetryCount ;
90
+ private final int closeRetryDelay ;
87
91
88
92
public DefaultAccessLogReceiver (final Executor logWriteExecutor , final File outputDirectory , final String logBaseName ) {
89
93
this (logWriteExecutor , outputDirectory .toPath (), logBaseName , null );
@@ -109,6 +113,7 @@ public DefaultAccessLogReceiver(final Executor logWriteExecutor, final Path outp
109
113
this (logWriteExecutor , outputDirectory , logBaseName , logNameSuffix , rotate , null );
110
114
}
111
115
116
+ @ SuppressWarnings ({ "removal" , "deprecation" })
112
117
public DefaultAccessLogReceiver (final Executor logWriteExecutor , final Path outputDirectory , final String logBaseName , final String logNameSuffix , boolean rotate , LogFileHeaderGenerator fileHeader ) {
113
118
this .logWriteExecutor = logWriteExecutor ;
114
119
this .outputDirectory = outputDirectory ;
@@ -119,6 +124,24 @@ public DefaultAccessLogReceiver(final Executor logWriteExecutor, final Path outp
119
124
this .pendingMessages = new ConcurrentLinkedDeque <>();
120
125
this .defaultLogFile = outputDirectory .resolve (logBaseName + this .logNameSuffix );
121
126
calculateChangeOverPoint ();
127
+
128
+ String property = System .getSecurityManager () == null ? System .getProperty (DEFAULT_RETRY_COUNT_PROPERTY )
129
+ : AccessController .doPrivileged (new PrivilegedAction <String >() {
130
+ @ Override
131
+ public String run () {
132
+ return System .getProperty (DEFAULT_RETRY_COUNT_PROPERTY );
133
+ }
134
+ });
135
+ this .closeRetryCount = property == null ? DEFAULT_RETRY_COUNT : Integer .parseInt (property );
136
+
137
+ property = System .getSecurityManager () == null ? System .getProperty (DEFAULT_RETRY_DELAY_PROPERTY )
138
+ : AccessController .doPrivileged (new PrivilegedAction <String >() {
139
+ @ Override
140
+ public String run () {
141
+ return System .getProperty (DEFAULT_RETRY_DELAY_PROPERTY );
142
+ }
143
+ });
144
+ this .closeRetryDelay = property == null ? DEFAULT_RETRY_DELAY : Integer .parseInt (property );
122
145
}
123
146
124
147
private void calculateChangeOverPoint () {
0 commit comments