Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/Analysis/Problem/Bukkit/ChunkLoadExceptionProblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@

class ChunkLoadExceptionProblem extends BukkitProblem
{
/**
* The start of the error and the lines after it, up to the start of the line that shows the cause.
* Whole lines are skipped possessively, so a long stack trace doesn't exhaust the backtrack limit.
*
* Example: "Encountered an unexpected exception\njava.lang.NullPointerException\n"
*/
protected const string UNEXPECTED_EXCEPTION = 'Encountered an unexpected exception\n(?:.*+\n)*?';

/**
* The start of a stack trace line up to the simple class name
*
* Example: "\tat net.minecraft.server.v1_8_R3."
*/
protected const string STACK_TRACE_PACKAGE = '\h*at (?:[\w$]++\.)*';

/**
* @inheritDoc
*/
Expand All @@ -18,14 +33,19 @@ public function getMessage(): string
}

/**
* Examples below UNEXPECTED_EXCEPTION:
* "at net.minecraft.server.v1_8_R3.ChunkRegionLoader.loadChunk(ChunkRegionLoader.java:70)"
* "at net.minecraft.server.v1_8_R3.ChunkRegionLoader.loadEntities(ChunkRegionLoader.java:433)"
* "net.minecraft.server.v1_13_R1.ReportedException: Exception generating new chunk"
*
* @inheritDoc
*/
public static function getPatterns(): array
{
return [
'/Encountered an unexpected exception(\n.*)*at.*ChunkRegionLoader\.loadChunk/',
'/Encountered an unexpected exception(\n.*)*at.*ChunkRegionLoader\.loadEntities/',
'/Encountered an unexpected exception(\n.*)*Exception generating new chunk/',
'/' . static::UNEXPECTED_EXCEPTION . static::STACK_TRACE_PACKAGE . 'ChunkRegionLoader\.loadChunk/',
'/' . static::UNEXPECTED_EXCEPTION . static::STACK_TRACE_PACKAGE . 'ChunkRegionLoader\.loadEntities/',
'/' . static::UNEXPECTED_EXCEPTION . '(?:[\w.$]++: )*Exception generating new chunk/',
'/Couldn\'t load chunk\n/'
];
}
Expand Down
2 changes: 0 additions & 2 deletions test/tests/Performance/PatternSafetyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Aternos\Codex\Minecraft\Test\Performance;

use Aternos\Codex\Analysis\PatternInsightInterface;
use Aternos\Codex\Minecraft\Analysis\Problem\Bukkit\ChunkLoadExceptionProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Forge\ClientOnlyModProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Forge\ModDependencyProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Forge\ModFatalProblem;
Expand Down Expand Up @@ -76,7 +75,6 @@ class PatternSafetyTest extends TestCase
* Which of them actually fails depends on whether PCRE JIT is enabled.
*/
protected const array KNOWN_UNSAFE_PATTERNS = [
ChunkLoadExceptionProblem::class => [0, 1, 2],
ClientOnlyModProblem::class => [0],
ModDependencyProblem::class => ["loading-failed-exception"],
ModFatalProblem::class => ["failed-to-load"],
Expand Down
Loading