Skip to content

Commit fb33c97

Browse files
committed
tweak Nullable annotations
Signed-off-by: neo <1100909+neowu@users.noreply.github.com>
1 parent d539be8 commit fb33c97

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

buildSrc/src/main/kotlin/frontend.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tasks.named("mkdir") {
66

77
interface Context {
88
@get:Inject
9-
val operation: ExecOperations
9+
val exec: ExecOperations
1010

1111
@get:Inject
1212
val fs: FileSystemOperations
@@ -24,15 +24,15 @@ afterEvaluate {
2424
tasks.register("buildFrontend") {
2525
group = "build"
2626
doLast {
27-
context.operation.exec {
27+
context.exec.exec {
2828
workingDir(frontendDir)
2929
commandLine(Frontend.commandLine(listOf("pnpm", "install")))
3030
}
3131

3232
val command = mutableListOf("pnpm", "run", "build")
3333
if (env != null) command.addAll(listOf("--env", env))
3434

35-
context.operation.exec {
35+
context.exec.exec {
3636
workingDir(frontendDir)
3737
commandLine(Frontend.commandLine(command))
3838
}

core-ng/src/main/java/core/framework/internal/log/ActionLog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public String errorCode() {
117117
return null;
118118
}
119119

120-
public void context(String key, Object... values) {
120+
public void context(String key, @Nullable Object... values) {
121121
List<String> contextValues = context.computeIfAbsent(key, k -> new ArrayList<>(Math.max(2, values.length))); // at least use 2 as init capacity, 0 capacity will result in size 10 array after adding
122122
for (Object value : values) {
123123
String contextValue = String.valueOf(value);

core-ng/src/main/java/core/framework/log/ActionLogContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static List<String> get(String key) {
3131
return values;
3232
}
3333

34-
public static void put(String key, Object... values) {
34+
public static void put(String key, @Nullable Object... values) {
3535
ActionLog actionLog = LogManager.CURRENT_ACTION_LOG.get();
3636
if (actionLog != null) { // here to check null is for unit testing the logManager.begin may not be called
3737
actionLog.context(key, values);

core-ng/src/test/java/core/framework/log/ActionLogContextTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ void withCurrentActionLog() {
3131

3232
assertThat(ActionLogContext.id()).isNotNull();
3333

34-
ActionLogContext.get("key");
3534
assertThat(ActionLogContext.get("key")).isEmpty();
3635
ActionLogContext.put("key", "value");
3736
assertThat(ActionLogContext.get("key")).contains("value");
3837

38+
String value = null;
39+
ActionLogContext.put("nullValue", value);
40+
assertThat(ActionLogContext.get("nullValue")).contains("null");
41+
3942
assertThat(ActionLogContext.track("db", 100)).isEqualTo(1);
4043
assertThat(ActionLogContext.track("db", 100)).isEqualTo(2);
4144

0 commit comments

Comments
 (0)