Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public boolean loadAe2Compat() {
public final ModConfigSpec.BooleanValue datagenOnStartup;
public final ModConfigSpec.BooleanValue loadRuntimeGeneratedResources;

public final ModConfigSpec.BooleanValue transactionCallerName;
// These should ideally be moved to the server config one day.
public final ModConfigSpec.BooleanValue debugCommands;
public final ModConfigSpec.IntValue maxDistillationTowerHeight;
Expand Down Expand Up @@ -93,6 +94,11 @@ private MIStartupConfig(MIConfigBuilder builder) {
.define("loadRuntimeGeneratedResources", false);
builder.popSection();

this.transactionCallerName = builder.start("transactionCallerName",
"Include Transaction Caller Name",
"Enable to have transfer transactions include the name of the class that called it.",
"Note that this comes at the cost of performance. It is recommended to not use this outside of debugging.")
.define("transactionCallerName", !FMLEnvironment.production);
this.debugCommands = builder.start("debugCommands",
"Debug commands",
"Enable UNSUPPORTED and DANGEROUS debug commands.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package aztech.modern_industrialization.thirdparty.fabrictransfer.api.transaction;

import aztech.modern_industrialization.config.MIStartupConfig;
import java.util.ArrayList;
import java.util.List;
import org.jspecify.annotations.Nullable;
Expand Down Expand Up @@ -98,7 +99,7 @@ public final class Transaction implements AutoCloseable, TransactionContext {
*/
public static Transaction openRoot() {
// Don't delegate to other method due to getCallerClass()
return TransactionManager.getManagerForThread().open(null, STACK_WALKER.getCallerClass());
return TransactionManager.getManagerForThread().open(null, MIStartupConfig.INSTANCE.transactionCallerName.getAsBoolean() ? STACK_WALKER.getCallerClass() : null);
}

/**
Expand All @@ -119,7 +120,7 @@ public static Transaction openRoot() {
*/
public static Transaction open(@Nullable TransactionContext parent) {
// Don't delegate to other method due to getCallerClass()
return TransactionManager.getManagerForThread().open(parent, STACK_WALKER.getCallerClass());
return TransactionManager.getManagerForThread().open(parent, MIStartupConfig.INSTANCE.transactionCallerName.getAsBoolean() ? STACK_WALKER.getCallerClass() : null);
}

public static Transaction hackyOpen() {
Expand Down Expand Up @@ -228,7 +229,7 @@ void validateOpen() {
* Gets what should be printed during exceptions to represent the caller class. This should include the package name as well.
*/
String getDebugName() {
return callerClass.toString();
return callerClass != null ? callerClass.toString() : "N/A";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Transaction open(@Nullable TransactionContext parent, Class<?> callerClass) {
} else if (currentDepth >= 0) {
String currentRoot = getOpenTransaction(0).getDebugName();
throw new IllegalStateException("A root transaction of `" + currentRoot + "` is already active on this thread " + thread + " when `"
+ callerClass + "` tried to open.");
+ (callerClass == null ? "N/A" : callerClass) + "` tried to open.");
}

Transaction current;
Expand Down
Loading