Skip to content

Commit db33754

Browse files
authored
[MNG-8150] Remove unused locale argument from FileSizeFormat (#1579)
## Summary Addressing #1575 (comment) - [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) --- https://issues.apache.org/jira/browse/MNG-8150
1 parent e995ba6 commit db33754

File tree

5 files changed

+11
-21
lines changed

5 files changed

+11
-21
lines changed

maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.maven.cli.transfer;
2020

2121
import java.io.PrintStream;
22-
import java.util.Locale;
2322

2423
import org.apache.maven.api.services.MessageBuilder;
2524
import org.apache.maven.api.services.MessageBuilderFactory;
@@ -72,7 +71,7 @@ public void transferSucceeded(TransferEvent event) {
7271

7372
TransferResource resource = event.getResource();
7473
long contentLength = event.getTransferredBytes();
75-
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
74+
FileSizeFormat format = new FileSizeFormat();
7675

7776
MessageBuilder message = messageBuilderFactory.builder();
7877
message.append(action).style(STYLE).append(' ').append(direction).append(' ');

maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.io.PrintStream;
2222
import java.util.Iterator;
2323
import java.util.LinkedHashMap;
24-
import java.util.Locale;
2524
import java.util.Map;
2625

2726
import org.apache.maven.api.services.MessageBuilderFactory;
@@ -37,7 +36,7 @@
3736
public class ConsoleMavenTransferListener extends AbstractMavenTransferListener {
3837

3938
private final Map<TransferResourceIdentifier, TransferResourceAndSize> transfers = new LinkedHashMap<>();
40-
private final FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH); // use in a synchronized fashion
39+
private final FileSizeFormat format = new FileSizeFormat(); // use in a synchronized fashion
4140
private final StringBuilder buffer = new StringBuilder(128); // use in a synchronized fashion
4241

4342
private final boolean printResourceNames;

maven-embedder/src/main/java/org/apache/maven/cli/transfer/FileSizeFormat.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*/
1919
package org.apache.maven.cli.transfer;
2020

21-
import java.util.Locale;
22-
2321
import org.apache.maven.api.services.MessageBuilder;
2422

2523
/**
@@ -101,8 +99,6 @@ public static ScaleUnit getScaleUnit(long size) {
10199
}
102100
}
103101

104-
public FileSizeFormat(Locale locale) {}
105-
106102
public String format(long size) {
107103
return format(size, null);
108104
}

maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*/
1919
package org.apache.maven.cli.transfer;
2020

21-
import java.util.Locale;
22-
2321
import org.eclipse.aether.transfer.AbstractTransferListener;
2422
import org.eclipse.aether.transfer.TransferCancelledException;
2523
import org.eclipse.aether.transfer.TransferEvent;
@@ -75,7 +73,7 @@ public void transferSucceeded(TransferEvent event) {
7573

7674
TransferResource resource = event.getResource();
7775
long contentLength = event.getTransferredBytes();
78-
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
76+
FileSizeFormat format = new FileSizeFormat();
7977

8078
StringBuilder message = new StringBuilder();
8179
message.append(action).append(' ').append(direction).append(' ').append(resource.getRepositoryId());

maven-embedder/src/test/java/org/apache/maven/cli/transfer/FileSizeFormatTest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*/
1919
package org.apache.maven.cli.transfer;
2020

21-
import java.util.Locale;
22-
2321
import org.apache.maven.cli.transfer.FileSizeFormat.ScaleUnit;
2422
import org.junit.jupiter.api.Test;
2523

@@ -30,15 +28,15 @@ class FileSizeFormatTest {
3028

3129
@Test
3230
void testNegativeSize() {
33-
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
31+
FileSizeFormat format = new FileSizeFormat();
3432

3533
long negativeSize = -100L;
3634
assertThrows(IllegalArgumentException.class, () -> format.format(negativeSize));
3735
}
3836

3937
@Test
4038
void testSize() {
41-
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
39+
FileSizeFormat format = new FileSizeFormat();
4240

4341
long _0_bytes = 0L;
4442
assertEquals("0 B", format.format(_0_bytes));
@@ -103,7 +101,7 @@ void testSize() {
103101

104102
@Test
105103
void testSizeWithSelectedScaleUnit() {
106-
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
104+
FileSizeFormat format = new FileSizeFormat();
107105

108106
long _0_bytes = 0L;
109107
assertEquals("0 B", format.format(_0_bytes));
@@ -206,22 +204,22 @@ void testSizeWithSelectedScaleUnit() {
206204

207205
@Test
208206
void testNegativeProgressedSize() {
209-
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
207+
FileSizeFormat format = new FileSizeFormat();
210208

211209
long negativeProgressedSize = -100L;
212210
assertThrows(IllegalArgumentException.class, () -> format.formatProgress(negativeProgressedSize, 10L));
213211
}
214212

215213
@Test
216214
void testNegativeProgressedSizeBiggerThanSize() {
217-
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
215+
FileSizeFormat format = new FileSizeFormat();
218216

219217
assertThrows(IllegalArgumentException.class, () -> format.formatProgress(100L, 10L));
220218
}
221219

222220
@Test
223221
void testProgressedSizeWithoutSize() {
224-
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
222+
FileSizeFormat format = new FileSizeFormat();
225223

226224
long _0_bytes = 0L;
227225
assertEquals("0 B", format.formatProgress(_0_bytes, -1L));
@@ -238,15 +236,15 @@ void testProgressedSizeWithoutSize() {
238236

239237
@Test
240238
void testProgressedBothZero() {
241-
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
239+
FileSizeFormat format = new FileSizeFormat();
242240

243241
long _0_bytes = 0L;
244242
assertEquals("0 B", format.formatProgress(_0_bytes, _0_bytes));
245243
}
246244

247245
@Test
248246
void testProgressedSizeWithSize() {
249-
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
247+
FileSizeFormat format = new FileSizeFormat();
250248

251249
long _0_bytes = 0L;
252250
long _400_bytes = 400L;

0 commit comments

Comments
 (0)