Skip to content

Commit 5c6d8cb

Browse files
committed
clean up system properties, deprecate javax/jakarta ones
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
1 parent 8065afc commit 5c6d8cb

4 files changed

Lines changed: 42 additions & 37 deletions

File tree

activation-registry/src/main/java/com/sun/activation/registries/LogSupport.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -23,12 +23,11 @@ class LogSupport {
2323

2424
static {
2525
try {
26-
debug = Boolean.getBoolean("jakarta.activation.debug") ||
27-
Boolean.getBoolean("javax.activation.debug");
26+
debug = Boolean.getBoolean("angus.activation.debug");
2827
} catch (Throwable t) {
2928
// ignore any errors
3029
}
31-
logger = Logger.getLogger("jakarta.activation");
30+
logger = Logger.getLogger("angus.activation");
3231
}
3332

3433
/**
@@ -39,12 +38,18 @@ private LogSupport() {
3938
}
4039

4140
public static void log(String msg) {
41+
if (!isLoggable()) {
42+
return;
43+
}
4244
if (debug)
4345
System.out.println(msg);
4446
logger.log(level, msg);
4547
}
4648

4749
public static void log(String msg, Throwable t) {
50+
if (!isLoggable()) {
51+
return;
52+
}
4853
if (debug)
4954
System.out.println(msg + "; Exception: " + t);
5055
logger.log(level, msg, t);

activation-registry/src/main/java/com/sun/activation/registries/MailcapFile.java

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,18 @@ public class MailcapFile implements MailcapRegistry {
5454

5555
static {
5656
try {
57-
addReverse = Boolean.getBoolean("jakarta.activation.addreverse") ||
58-
Boolean.getBoolean("javax.activation.addreverse");
57+
addReverse = Boolean.getBoolean("angus.activation.addreverse");
58+
// deprecated in 1.1.0:
59+
String prop = System.getProperty("jakarta.activation.addreverse");
60+
if (prop != null) {
61+
LogSupport.log("'jakarta.activation.addreverse' property is deprecated, use 'angus.activation.addreverse' instead");
62+
addReverse = Boolean.parseBoolean(prop);
63+
}
64+
prop = System.getProperty("javax.activation.addreverse");
65+
if (prop != null) {
66+
LogSupport.log("'javax.activation.addreverse' property is deprecated, use 'angus.activation.addreverse' instead");
67+
addReverse = Boolean.parseBoolean(prop);
68+
}
5969
} catch (Throwable t) {
6070
// ignore any errors
6171
}
@@ -68,8 +78,7 @@ public class MailcapFile implements MailcapRegistry {
6878
* @throws IOException for I/O errors
6979
*/
7080
public MailcapFile(String new_fname) throws IOException {
71-
if (LogSupport.isLoggable())
72-
LogSupport.log("new MailcapFile: file " + new_fname);
81+
LogSupport.log("new MailcapFile: file " + new_fname);
7382
try (BufferedReader reader = new BufferedReader(new FileReader(new_fname))) {
7483
parse(reader);
7584
}
@@ -82,17 +91,15 @@ public MailcapFile(String new_fname) throws IOException {
8291
* @throws IOException for I/O errors
8392
*/
8493
public MailcapFile(InputStream is) throws IOException {
85-
if (LogSupport.isLoggable())
86-
LogSupport.log("new MailcapFile: InputStream");
94+
LogSupport.log("new MailcapFile: InputStream");
8795
parse(new BufferedReader(new InputStreamReader(is, StandardCharsets.ISO_8859_1)));
8896
}
8997

9098
/**
9199
* Mailcap file default constructor.
92100
*/
93101
public MailcapFile() {
94-
if (LogSupport.isLoggable())
95-
LogSupport.log("new MailcapFile: default");
102+
LogSupport.log("new MailcapFile: default");
96103
}
97104

98105
/**
@@ -232,8 +239,7 @@ private Map<String, List<String>> mergeResults(Map<String, List<String>> first,
232239
* @param mail_cap the mailcap string
233240
*/
234241
public void appendToMailcap(String mail_cap) {
235-
if (LogSupport.isLoggable())
236-
LogSupport.log("appendToMailcap: " + mail_cap);
242+
LogSupport.log("appendToMailcap: " + mail_cap);
237243
try {
238244
parse(new BufferedReader(new StringReader(mail_cap)));
239245
} catch (IOException ex) {
@@ -300,8 +306,7 @@ protected void parseLine(String mailcapEntry)
300306
MailcapTokenizer tokenizer = new MailcapTokenizer(mailcapEntry);
301307
tokenizer.setIsAutoquoting(false);
302308

303-
if (LogSupport.isLoggable())
304-
LogSupport.log("parse: " + mailcapEntry);
309+
LogSupport.log("parse: " + mailcapEntry);
305310
// parse the primary type
306311
int currentToken = tokenizer.nextToken();
307312
if (currentToken != MailcapTokenizer.STRING_TOKEN) {
@@ -339,8 +344,7 @@ protected void parseLine(String mailcapEntry)
339344

340345
String mimeType = primaryType + "/" + subType;
341346

342-
if (LogSupport.isLoggable())
343-
LogSupport.log(" Type: " + mimeType);
347+
LogSupport.log(" Type: " + mimeType);
344348

345349
// now setup the commands hashtable
346350
Map<String, List<String>> commands = new LinkedHashMap<>(); // keep commands in order found
@@ -435,8 +439,7 @@ protected void parseLine(String mailcapEntry)
435439
} else {
436440

437441
// setup the class entry list
438-
if (LogSupport.isLoggable())
439-
LogSupport.log(" Command: " + commandName +
442+
LogSupport.log(" Command: " + commandName +
440443
", Class: " + paramValue);
441444
List<String> classes = commands.computeIfAbsent(commandName, k -> new ArrayList<>());
442445
if (addReverse)
@@ -456,8 +459,7 @@ protected void parseLine(String mailcapEntry)
456459
if (curcommands == null) {
457460
masterHash.put(mimeType, commands);
458461
} else {
459-
if (LogSupport.isLoggable())
460-
LogSupport.log("Merging commands for type " + mimeType);
462+
LogSupport.log("Merging commands for type " + mimeType);
461463
// have to merge current and new commands
462464
// first, merge list of classes for commands already known
463465
Iterator<String> cn = curcommands.keySet().iterator();
@@ -516,13 +518,6 @@ protected static void reportParseError(int expectedToken,
516518
protected static void reportParseError(int expectedToken,
517519
int otherExpectedToken, int anotherExpectedToken, int actualToken,
518520
String actualTokenValue) throws MailcapParseException {
519-
if (LogSupport.isLoggable())
520-
LogSupport.log("PARSE ERROR: " + "Encountered a " +
521-
MailcapTokenizer.nameForToken(actualToken) + " token (" +
522-
actualTokenValue + ") while expecting a " +
523-
MailcapTokenizer.nameForToken(expectedToken) + ", a " +
524-
MailcapTokenizer.nameForToken(otherExpectedToken) + ", or a " +
525-
MailcapTokenizer.nameForToken(anotherExpectedToken) + " token.");
526521
throw new MailcapParseException("Encountered a " +
527522
MailcapTokenizer.nameForToken(actualToken) + " token (" +
528523
actualTokenValue + ") while expecting a " +

activation-registry/src/main/java/com/sun/activation/registries/MimeTypeFile.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ private void parseEntry(String line) {
166166
lt.hasMoreTokens())
167167
value = lt.nextToken();
168168
if (value == null) {
169-
if (LogSupport.isLoggable())
170-
LogSupport.log("Bad .mime.types entry: " + line);
169+
LogSupport.log("Bad .mime.types entry: " + line);
171170
return;
172171
}
173172
if (name.equals("type"))
@@ -179,8 +178,7 @@ else if (name.equals("exts")) {
179178
MimeTypeEntry entry =
180179
new MimeTypeEntry(mime_type, file_ext);
181180
type_hash.put(file_ext, entry);
182-
if (LogSupport.isLoggable())
183-
LogSupport.log("Added: " + entry);
181+
LogSupport.log("Added: " + entry);
184182
}
185183
}
186184
}
@@ -201,8 +199,7 @@ else if (name.equals("exts")) {
201199
file_ext = strtok.nextToken();
202200
entry = new MimeTypeEntry(mime_type, file_ext);
203201
type_hash.put(file_ext, entry);
204-
if (LogSupport.isLoggable())
205-
LogSupport.log("Added: " + entry);
202+
LogSupport.log("Added: " + entry);
206203
}
207204
}
208205
}
@@ -294,7 +291,7 @@ public String nextToken() {
294291
String s;
295292

296293
if (filter) {
297-
StringBuffer sb = new StringBuffer();
294+
StringBuilder sb = new StringBuilder();
298295
for (int i = start + 1; i < currentPosition - 1; i++) {
299296
c = str.charAt(i);
300297
if (c != '\\')

docs/src/main/resources/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,22 @@ to `org.eclipse.angus.activation` and package name from
2828

2929
## December TBD, 2022 - Angus Activation 1.1.0 Final Release
3030

31-
Adds built-in support for GraalVM native-image, support for OSGi Mediator Specification.
31+
Adds built-in support for GraalVM native-image, support for OSGi Mediator Specification,
32+
clean up supported system properties.
33+
34+
| system property | description | value |
35+
|:----------------------------|:------------------------------------------------------|:----------------------------|
36+
| angus.activation.addreverse | Read mailcap file from the end | **false** (default) / true |
37+
| angus.activation.debug | Print log messages, logger name is `angus.activation` | **false** (default) / true |
3238

3339

3440
| native-image option | description | value |
3541
|:-------------------------------------|:------------------------------------------|:---------------------------|
3642
| angus.activation.native-image.enable | Turn on built-in support for native image | false / **true** (default) |
3743
| angus.activation.native-image.trace | Print log messages to `System.out` | **false** (default) / true |
3844

45+
System properties with `jakarta.activation`/`javax.activation` prefix are deprecated and future
46+
versions of Angus Activation ignore them.
3947

4048
## December 14, 2021 - Angus Activation 1.0.0 Final Release
4149

0 commit comments

Comments
 (0)