Skip to content

Commit 06b2d65

Browse files
committed
Update 1.2.44
1 parent 7e8570b commit 06b2d65

File tree

8 files changed

+144
-18
lines changed

8 files changed

+144
-18
lines changed

common/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ dependencies {
1010
// TODO: Don't forget to update DependencyHelper and ":dev" project
1111
api 'org.ow2.asm:asm-util:9.7'
1212
api 'org.ow2.asm:asm-commons:9.7'
13-
api 'org.semver4j:semver4j:5.2.2'
13+
api 'org.semver4j:semver4j:5.3.0'
1414
// api 'org.spongepowered:mixin:0.8.5'
15-
api 'net.fabricmc:sponge-mixin:0.13.2+mixin.0.8.5' // <- https://maven.fabricmc.net/net/fabricmc/sponge-mixin/
16-
api 'io.github.llamalad7:mixinextras-common:0.3.5' // <- https://github.com/LlamaLad7/MixinExtras/releases
17-
api 'com.github.bawnorton.mixinsquared:mixinsquared-common:0.1.2-beta.5' // <- https://github.com/Bawnorton/MixinSquared/releases
15+
api 'net.fabricmc:sponge-mixin:0.13.4+mixin.0.8.5' // <- https://maven.fabricmc.net/net/fabricmc/sponge-mixin/
16+
api 'io.github.llamalad7:mixinextras-common:0.3.6' // <- https://github.com/LlamaLad7/MixinExtras/releases
17+
api 'com.github.bawnorton.mixinsquared:mixinsquared-common:0.1.2-beta.6' // <- https://github.com/Bawnorton/MixinSquared/releases
1818
api 'it.unimi.dsi:fastutil-core:8.5.13'
1919

2020
// Mixin dependencies

common/src/main/java/com/fox2code/foxloader/config/ConfigStructure.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,13 @@ private static JsonElement getElementJsonObject(JsonObject jsonObject, String pa
238238
int tmpIndex;
239239
while ((tmpIndex = path.indexOf('.', index)) != -1) {
240240
String subKey = path.substring(index, tmpIndex);
241-
if (!directJsonObject.has(subKey)) return null;
241+
if (directJsonObject == null || !directJsonObject.has(subKey)) {
242+
return null;
243+
}
242244
directJsonObject = directJsonObject.getAsJsonObject(subKey);
243245
index = tmpIndex + 1;
244246
}
245-
return directJsonObject.get(path.substring(index));
247+
return directJsonObject == null ? null : directJsonObject.get(path.substring(index));
246248
}
247249

248250
private static void setElementJsonObject(JsonObject jsonObject, String path, JsonElement jsonElement) {

common/src/main/java/com/fox2code/foxloader/launcher/DependencyHelper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ public class DependencyHelper {
3535
new Dependency("org.ow2.asm:asm-commons:9.7", MAVEN_CENTRAL, "org.objectweb.asm.commons.InstructionAdapter"),
3636
new Dependency("org.ow2.asm:asm-util:9.7", MAVEN_CENTRAL, "org.objectweb.asm.util.CheckClassAdapter"),
3737
GSON_DEPENDENCY, new Dependency("com.google.guava:guava:21.0", MAVEN_CENTRAL, "com.google.common.io.Files"),
38-
new Dependency("org.semver4j:semver4j:5.2.2", MAVEN_CENTRAL, "org.semver4j.Semver"),
38+
new Dependency("org.semver4j:semver4j:5.3.0", MAVEN_CENTRAL, "org.semver4j.Semver"),
3939
new Dependency("org.apache.commons:commons-lang3:3.3.2", MAVEN_CENTRAL, "org.apache.commons.lang3.tuple.Pair"),
4040
new Dependency("org.luaj:luaj-jse:3.0.1", MAVEN_CENTRAL, "org.luaj.vm2.Globals"),
41-
new Dependency("it.unimi.dsi:fastutil-core:8.5.12", MAVEN_CENTRAL, "it.unimi.dsi.fastutil.Pair"),
41+
new Dependency("it.unimi.dsi:fastutil-core:8.5.13", MAVEN_CENTRAL, "it.unimi.dsi.fastutil.Pair"),
4242
// new Dependency("org.spongepowered:mixin:0.8.5", SPONGE_POWERED, "org.spongepowered.asm.mixin.Mixins"),
43-
new Dependency("net.fabricmc:sponge-mixin:0.13.2+mixin.0.8.5", FABRIC_MC, "org.spongepowered.asm.mixin.Mixins"),
44-
new Dependency("io.github.llamalad7:mixinextras-common:0.3.5",
43+
new Dependency("net.fabricmc:sponge-mixin:0.13.4+mixin.0.8.5", FABRIC_MC, "org.spongepowered.asm.mixin.Mixins"),
44+
new Dependency("io.github.llamalad7:mixinextras-common:0.3.6",
4545
MAVEN_CENTRAL, "com.llamalad7.mixinextras.MixinExtrasBootstrap"),
46-
new Dependency("com.github.bawnorton.mixinsquared:mixinsquared-common:0.1.2-beta.5",
46+
new Dependency("com.github.bawnorton.mixinsquared:mixinsquared-common:0.1.2-beta.6",
4747
JITPACK, "com.bawnorton.mixinsquared.MixinSquaredBootstrap",
48-
"https://github.com/Bawnorton/MixinSquared/releases/download/0.1.2-beta.5/mixinsquared-common-0.1.2-beta.5.jar"),
48+
"https://github.com/Bawnorton/MixinSquared/releases/download/0.1.2-beta.6/mixinsquared-common-0.1.2-beta.6.jar"),
4949
jFallback, // jFallback have special handling in dev plugin
5050
};
5151

common/src/main/java/com/fox2code/foxloader/loader/ModLoader.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.fox2code.foxloader.registry.CommandCompat;
1313
import com.fox2code.foxloader.registry.RegisteredEntity;
1414
import com.fox2code.foxloader.registry.RegisteredItemStack;
15+
import com.fox2code.foxloader.utils.WatchdogTimer;
1516
import com.fox2code.jfallback.JFallbackClassLoader;
1617
import com.google.gson.Gson;
1718
import com.google.gson.GsonBuilder;
@@ -516,21 +517,25 @@ public static void runOnPostInit(Runnable runnable) {
516517
static final AsyncItrLinkedList<LifecycleListener> listeners = new AsyncItrLinkedList<>();
517518

518519
public static class Internal {
519-
public static Properties fallbackTranslations = new Properties();
520+
public static final Properties fallbackTranslations = new Properties();
521+
public static final WatchdogTimer watchdogTimer = new WatchdogTimer(true);
520522

521523
public static void notifyOnTick() {
524+
watchdogTimer.heartbeat();
522525
for (ModContainer modContainer : modContainers.values()) {
523526
modContainer.notifyOnTick();
524527
}
525528
}
526529

527530
public static void notifyOnServerStart(NetworkPlayer.ConnectionType connectionType) {
531+
watchdogTimer.megaHeartbeat();
528532
for (LifecycleListener lifecycleListener : listeners) {
529533
lifecycleListener.onServerStart(connectionType);
530534
}
531535
}
532536

533537
public static void notifyOnServerStop(NetworkPlayer.ConnectionType connectionType) {
538+
watchdogTimer.megaHeartbeat();
534539
for (LifecycleListener lifecycleListener : listeners) {
535540
lifecycleListener.onServerStop(connectionType);
536541
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.fox2code.foxloader.utils;
2+
3+
import java.lang.ref.WeakReference;
4+
import java.util.Map;
5+
import java.util.concurrent.CopyOnWriteArrayList;
6+
7+
final class WatchdogThread extends Thread {
8+
private static final long T1_SECONDS = 1000L;
9+
private static final long T1_9_SECONDS = 1900L;
10+
private static WatchdogThread watchdogThread;
11+
private final CopyOnWriteArrayList<WeakReference<WatchdogTimer>> watchdogTimers;
12+
private long lastStackDump;
13+
14+
private WatchdogThread() {
15+
this.setDaemon(true);
16+
this.setPriority(Thread.MIN_PRIORITY);
17+
this.setName("FoxLoader - Watchdog Thread");
18+
this.watchdogTimers = new CopyOnWriteArrayList<>();
19+
this.lastStackDump = System.currentTimeMillis();
20+
Runtime.getRuntime().addShutdownHook(new Thread(
21+
this::interrupt, "FoxLoader - Watchdog Shutdown Thread"));
22+
}
23+
24+
@Override
25+
public void run() {
26+
try {
27+
boolean exit = false;
28+
while (!(exit || this.isInterrupted())) {
29+
//noinspection BusyWait
30+
Thread.sleep(T1_SECONDS);
31+
boolean needDump = false;
32+
for (WeakReference<WatchdogTimer> watchdogTimerRef : this.watchdogTimers) {
33+
WatchdogTimer watchdogTimer = watchdogTimerRef.get();
34+
if (watchdogTimer != null && watchdogTimer.isEnabled()) {
35+
long computingFor = watchdogTimer.getComputingFor();
36+
if (computingFor / T1_SECONDS == 10L) {
37+
needDump = true;
38+
if (watchdogTimer.isEssential()) {
39+
exit = true;
40+
}
41+
} else if (computingFor / T1_SECONDS == 5L) {
42+
needDump = true;
43+
}
44+
}
45+
}
46+
if (needDump) {
47+
doCompleteThreadDump(exit);
48+
}
49+
}
50+
} catch (InterruptedException ignored) {}
51+
}
52+
53+
static void registerTimer(WatchdogTimer watchdogTimer) {
54+
if (watchdogThread == null) {
55+
watchdogThread = new WatchdogThread();
56+
watchdogThread.start();
57+
}
58+
watchdogThread.watchdogTimers.add(new WeakReference<>(watchdogTimer));
59+
}
60+
61+
private void doCompleteThreadDump(boolean andExit) {
62+
if (System.currentTimeMillis() - this.lastStackDump < T1_9_SECONDS && !andExit) return;
63+
this.lastStackDump = System.currentTimeMillis();
64+
System.out.println((andExit ? "Fatal freeze" : "Freeze") + " detected, creating stack dump:");
65+
System.out.println();
66+
for (Map.Entry<Thread, StackTraceElement[]> stackTrace : Thread.getAllStackTraces().entrySet()) {
67+
Thread thread = stackTrace.getKey();
68+
System.out.println(thread.getName() + " (Priority: " +
69+
thread.getPriority() + (thread.isDaemon() ? ", Daemon)" : ")"));
70+
for (StackTraceElement stackTraceElement : stackTrace.getValue()) {
71+
System.out.println(" " + stackTraceElement.toString());
72+
}
73+
System.out.println();
74+
}
75+
if (andExit) {
76+
System.exit(1);
77+
}
78+
}
79+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.fox2code.foxloader.utils;
2+
3+
public final class WatchdogTimer {
4+
private final boolean essential;
5+
private volatile long lastCheck;
6+
private volatile long megaLastCheck;
7+
private boolean enabled;
8+
9+
public WatchdogTimer(boolean essential) {
10+
WatchdogThread.registerTimer(this);
11+
this.essential = essential;
12+
this.lastCheck = 0;
13+
this.megaHeartbeat();
14+
this.enabled = true;
15+
}
16+
17+
public boolean isEssential() {
18+
return this.essential;
19+
}
20+
21+
long getComputingFor() {
22+
return this.lastCheck == 0 ? 0 : System.currentTimeMillis() - Math.max(this.lastCheck, this.megaLastCheck);
23+
}
24+
25+
public void heartbeat() {
26+
this.lastCheck = System.currentTimeMillis();
27+
}
28+
29+
public void megaHeartbeat() {
30+
this.megaLastCheck = System.currentTimeMillis() + 10000L;
31+
}
32+
33+
public boolean isEnabled() {
34+
return this.enabled;
35+
}
36+
37+
public void setEnabled(boolean enabled) {
38+
this.enabled = enabled;
39+
}
40+
}

dev/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies {
2626
//compileOnly localGroovy()
2727
api 'com.fox2code:JFallback:0.1.1'
2828
api 'com.google.code.gson:gson:2.10.1'
29-
api 'org.semver4j:semver4j:5.2.2'
29+
api 'org.semver4j:semver4j:5.3.0'
3030
api 'org.ow2.asm:asm-commons:9.7'
3131
api 'org.ow2.asm:asm-util:9.7'
3232
// Need LWJGL 2 for game decompilation.

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ org.gradle.parallel=true
33
org.gradle.jvmargs=-Xmx1024m -XX:-UseGCOverheadLimit -Dfile.encoding=UTF-8
44

55
# FoxLoader properties
6-
foxloader.version=1.2.43
6+
foxloader.version=1.2.44
77
foxloader.lastReIndevTransformerChanges=1.2.39
88
# https://www.jitpack.io/#com.fox2code/FoxLoader
99

@@ -18,8 +18,8 @@ reindev.version=2.8.1_5
1818
reindev.version.allowFrom=2.8.1_4
1919

2020
#Spark properties
21-
spark.dependency=maven.modrinth:spark:1.10.58-fabric
22-
spark.version=1.10.58
21+
spark.dependency=maven.modrinth:spark:1.10.65-fabric
22+
spark.version=1.10.65
2323

2424
#VineFlower properties
25-
vineflower.dependency=org.vineflower:vineflower:1.10.0
25+
vineflower.dependency=org.vineflower:vineflower:1.10.1

0 commit comments

Comments
 (0)