StackOverflowError when using `DefaultValue.parsed("")`
まだ誰も着手していません。
評価
調査の方向性
CommandTree.java から始め、特にスタックトレースに現れる determineAccess と attemptParseUnambiguousChild を調べます。DefaultValue.parsed("") と @Default("") 用に提供された 2 つの JUnit ケースで失敗を再現します。両方の実行が StackOverflowError なしで完了し、コマンドコンテキストに arg の空文字列が含まれていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
When using DefaultValue.parsed("") or @Default(""), and the command input does not contain the corresponding Parameter, a StackOverflowError is thrown.
Test cases for reproduction:
DefaultValue.parsed("")
//
// MIT License
//
// Copyright (c) 2024 Incendo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package org.incendo.cloud.issue;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.TestCommandSender;
import org.incendo.cloud.component.DefaultValue;
import org.incendo.cloud.execution.CommandResult;
import org.incendo.cloud.execution.ExecutionCoordinator;
import org.incendo.cloud.internal.CommandRegistrationHandler;
import org.incendo.cloud.parser.standard.StringParser;
import org.junit.jupiter.api.Test;
import static com.google.common.truth.Truth.assertThat;
/**
* Test for https://github.com/Incendo/cloud/issues/todo.
*/
class ProbableIssue {
@Test
void emptyDefaultDoesNotCauseStackOverflow() {
// Arrange
final CommandManager<TestCommandSender> commandManager = new CommandManager<TestCommandSender>(
ExecutionCoordinator.simpleCoordinator(),
CommandRegistrationHandler.nullCommandRegistrationHandler()
) {
@Override
public boolean hasPermission(
final @NonNull TestCommandSender sender,
final @NonNull String permission
) {
return true;
}
};
commandManager.command(
commandManager.commandBuilder("test")
.optional("arg", StringParser.stringParser(), DefaultValue.parsed(""))
.handler(context -> {})
.build());
// Act
final CommandResult<?> result = commandManager.commandExecutor().executeCommand(new TestCommandSender(), "test").join();
// Assert
assertThat(result.commandContext().<String>get("arg")).isEqualTo("");
}
}
@Default("")
//
// MIT License
//
// Copyright (c) 2024 Incendo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package org.incendo.cloud.annotations.issue;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.annotations.AnnotationParser;
import org.incendo.cloud.annotations.Command;
import org.incendo.cloud.annotations.Default;
import org.incendo.cloud.annotations.TestCommandManager;
import org.incendo.cloud.annotations.TestCommandSender;
import org.incendo.cloud.execution.CommandResult;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static com.google.common.truth.Truth.assertThat;
class ProbableIssue {
private CommandManager<TestCommandSender> commandManager;
private AnnotationParser<TestCommandSender> annotationParser;
@BeforeEach
void setup() {
this.commandManager = new TestCommandManager();
this.annotationParser = new AnnotationParser<>(
this.commandManager,
TestCommandSender.class
);
}
@Test
void test() {
// Arrange
this.annotationParser.parse(new TestClass());
// Act
final CommandResult<?> result =
this.commandManager.commandExecutor().executeCommand(new TestCommandSender(), "empty").join();
// Assert
assertThat(result.commandContext().<String>get("arg")).isEqualTo("");
}
static class TestClass {
@Command("empty [arg]")
public void empty(@Default("") String arg) {
}
}
}
Relevant output of my example test case:
java.lang.StackOverflowError
java.util.concurrent.CompletionException: java.lang.StackOverflowError
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1159)
at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
at org.incendo.cloud.execution.ExecutionCoordinatorImpl$NonSchedulingExecutor.execute(ExecutionCoordinatorImpl.java:53)
at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1184)
at java.base/java.util.concurrent.CompletableFuture.thenComposeAsync(CompletableFuture.java:2352)
at org.incendo.cloud.CommandTree.lambda$parseCommand$4(CommandTree.java:306)
at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1187)
at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2341)
at org.incendo.cloud.CommandTree.parseCommand(CommandTree.java:289)
at org.incendo.cloud.CommandTree.parseDirect(CommandTree.java:205)
at org.incendo.cloud.CommandTree.lambda$parse$0(CommandTree.java:180)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
at org.incendo.cloud.execution.ExecutionCoordinatorImpl$NonSchedulingExecutor.execute(ExecutionCoordinatorImpl.java:53)
at java.base/java.util.concurrent.CompletableFuture.asyncSupplyStage(CompletableFuture.java:1782)
at java.base/java.util.concurrent.CompletableFuture.supplyAsync(CompletableFuture.java:2005)
at org.incendo.cloud.util.CompletableFutures.scheduleOn(CompletableFutures.java:70)
at org.incendo.cloud.CommandTree.parse(CommandTree.java:180)
at org.incendo.cloud.execution.ExecutionCoordinatorImpl.coordinateExecution(ExecutionCoordinatorImpl.java:98)
at org.incendo.cloud.StandardCommandExecutor.executeCommand(StandardCommandExecutor.java:91)
at org.incendo.cloud.StandardCommandExecutor.executeCommand(StandardCommandExecutor.java:65)
at org.incendo.cloud.execution.CommandExecutor.executeCommand(CommandExecutor.java:63)
at org.incendo.cloud.issue.ProbableIssue.emptyDefaultDoesNotCauseStackOverflow(ProbableIssue.java:66)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
<internal lines not relevant to this issue>
Suppressed: java.util.concurrent.CompletionException: java.lang.StackOverflowError
at org.incendo.cloud.StandardCommandExecutor.lambda$executeCommand$0(StandardCommandExecutor.java:77)
at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
at java.base/java.util.concurrent.CompletableFuture.uniWhenCompleteStage(CompletableFuture.java:887)
at java.base/java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:2357)
... 83 more
Caused by: java.lang.StackOverflowError
<internal lines not relevant to this issue>
at io.leangen.geantyref.GenericTypeReflector.isSuperType(GenericTypeReflector.java:400)
at org.incendo.cloud.CommandTree.determineAccess(CommandTree.java:1037)
at org.incendo.cloud.CommandTree.attemptParseUnambiguousChild(CommandTree.java:399)
at org.incendo.cloud.CommandTree.attemptParseUnambiguousChild(CommandTree.java:435)
at org.incendo.cloud.CommandTree.attemptParseUnambiguousChild(CommandTree.java:435)
<CommandTree.java:435 repeated a lot>
Caused by: [CIRCULAR REFERENCE: java.lang.StackOverflowError]
- 主要言語
- Java
- スター
- 546
- フォーク
- 61
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Incendo/cloud のほかの issue
-
難易度 2/5 半日 初心者へのやさしさ 76/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 50/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
erkamyaman/rust-anything#963 ·
メンテナーはふだん 1 日以内に返信
-
Deferred
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Sanne/incus-spawn#2768 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
morluto/rea#15041 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] Spring SDK returns null for successful plain-text String responses対応中かも @Chrisp12138 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信