Skip to content

Commit 115f325

Browse files
authored
Update version to 1.3.2 (rabbitmq#132)
1 parent e9e6973 commit 115f325

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.alipay.sofa.common</groupId>
66
<artifactId>sofa-common-tools</artifactId>
7-
<version>1.3.1</version>
7+
<version>1.3.2</version>
88
<packaging>jar</packaging>
99

1010
<name>${project.groupId}:${project.artifactId}</name>

src/main/java/com/alipay/sofa/common/code/LogCode2Description.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.io.InputStream;
2424
import java.io.InputStreamReader;
25+
import java.util.HashMap;
2526
import java.util.Locale;
2627
import java.util.Map;
2728
import java.util.Properties;
@@ -95,7 +96,7 @@ public static void removeCodeSpace(SpaceId spaceId) {
9596
}
9697

9798
private String logFormat;
98-
private Properties properties;
99+
private Map<String, String> codeMap = new ConcurrentHashMap<>();
99100

100101
private LogCode2Description(SpaceId spaceId) {
101102
logFormat = spaceId.getSpaceName().toUpperCase() + "-%s: %s";
@@ -110,25 +111,30 @@ private LogCode2Description(SpaceId spaceId) {
110111
}
111112

112113
try (InputStream in = this.getClass().getClassLoader().getResourceAsStream(fileName)) {
113-
properties = new Properties();
114+
Properties properties = new Properties();
114115

115116
if (in == null) {
116117
ReportUtil.reportError(String.format("Code file for CodeSpace \"%s\" doesn't exist!", spaceId.getSpaceName()));
117118
} else {
118119
InputStreamReader reader = new InputStreamReader(in);
119120
properties.load(reader);
120121
}
122+
for (Map.Entry<?, ?> entry: properties.entrySet()) {
123+
String key = (String) entry.getKey();
124+
codeMap.put(key, String.format(logFormat, key, entry.getValue()));
125+
}
121126
} catch (Throwable e) {
122127
ReportUtil.reportError(String.format("Code space \"%s\" initializing failed!", spaceId.getSpaceName()), e);
123128
}
124129
}
125130

126131
public String convert(String code) {
127-
Object description = properties.get(code);
132+
String description = codeMap.get(code);
128133
if (description == null) {
129-
description = "Unknown Code";
134+
description = String.format(logFormat, code, "Unknown Code");
135+
codeMap.put(code, description);
136+
return description;
130137
}
131-
132-
return String.format(logFormat, code, description);
138+
return description;
133139
}
134140
}

0 commit comments

Comments
 (0)