Skip to content

Calling getFilter on a peripheral without filters set causes an error #838

Description

@rassvet-ii

Describe

As described in the title, calling getFilter on peripherals such as basin with no filter set will result in an error.
Although this can be handled by using pcall, as with other cases of cc, I think it should return nil.
It seems this is caused by the null value returned here is being passed to the HashMap constructor here.

This feature is extremely useful when there are many basins on the network and find them so thanks!
(btw it was really hard to figure out who added this peripheral type)

Steps to reproduce

  1. Place and connect any create block that has a filter slot
  2. Run this code
peripheral.find('filtering_behaviour').getFilter()
  1. Error occured
lua[1]:1 Java Exception Thrown
java.lang.NullPointerException: Cannot invoke "java.util.Map.size()" because "m" is null
Stacktrace from log
[16:35:27] [Server thread/ERROR] [da.co.co.co.LuaContext/COMPUTER_ERROR.JAVA]: Error running task
java.lang.NullPointerException: Cannot invoke "java.util.Map.size()" because "m" is null
	at java.base/java.util.HashMap.putMapEntries(HashMap.java:503) ~[?:?] {re:mixin}
	at java.base/java.util.HashMap.<init>(HashMap.java:492) ~[?:?] {re:mixin}
	at TRANSFORMER/advancedperipherals@1.21.1-0.8.1a/de.srendi.advancedperipherals.common.addons.create.FilteringBehaviourIntegration.getFilter(FilteringBehaviourIntegration.java:30) ~[AdvancedPeripherals-1.21.1-0.8.1a.jar%23517!/:1.21.1-0.8.1a] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.asm.PeripheralMethodSupplier.lambda$static$1(PeripheralMethodSupplier.java:28) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.asm.PeripheralMethodSupplier.lambda$static$4(PeripheralMethodSupplier.java:35) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.api.lua.TaskCallback.execute(TaskCallback.java:28) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.computer.GuardedLuaContext.lambda$issueMainThreadTask$0(GuardedLuaContext.java:45) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.computer.GuardedLuaContext.lambda$issueMainThreadTask$0(GuardedLuaContext.java:45) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.computer.LuaContext.lambda$issueMainThreadTask$0(LuaContext.java:29) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.computer.mainthread.MainThreadExecutor.execute(MainThreadExecutor.java:138) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.computer.mainthread.MainThread.tick(MainThread.java:139) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.shared.computer.core.ServerContext.tick(ServerContext.java:154) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:mixin,re:classloading,pl:mixin:APP:ccsecureboot.mixin.json:ServerContextAccessor from mod ccsecureboot,pl:mixin:A}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.shared.CommonHooks.onServerTickStart(CommonHooks.java:75) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.shared.ForgeCommonHooks.onServerTick(ForgeCommonHooks.java:39) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at MC-BOOTSTRAP/net.neoforged.bus/net.neoforged.bus.EventBus.post(EventBus.java:360) ~[bus-8.0.5.jar%23164!/:?] {}
	at MC-BOOTSTRAP/net.neoforged.bus/net.neoforged.bus.EventBus.post(EventBus.java:328) ~[bus-8.0.5.jar%23164!/:?] {}
	at TRANSFORMER/neoforge@21.1.250/net.neoforged.neoforge.event.EventHooks.fireServerTickPre(EventHooks.java:1010) ~[neoforge-21.1.250-universal.jar%23507!/:?] {re:mixin,re:classloading}
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:915) ~[client-1.21.1-20240808.144430-srg.jar%23506!/:?] {re:mixin,pl:accesstransformer:B,pl:connector_pre_launch:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:connector_pre_launch:A}
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.client.server.IntegratedServer.tickServer(IntegratedServer.java:110) ~[client-1.21.1-20240808.144430-srg.jar%23506!/:?] {re:mixin,pl:connector_pre_launch:A,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:openpartiesandclaims.mixins.json:MixinIntegratedServer from mod openpartiesandclaims,pl:mixin:APP:modernfix-modernfix.mixins.json:perf.thread_priorities.IntegratedServerMixin from mod modernfix,pl:mixin:APP:modernfix-modernfix.mixins.json:perf.suspend_integrated_server_during_load.IntegratedServerMixin from mod modernfix,pl:mixin:APP:blueprint.mixins.json:client.IntegratedServerMixin from mod blueprint,pl:mixin:APP:sable.mixins.json:toast.IntegratedServerMixin from mod sable,pl:mixin:APP:lithostitched.mixins.json:client.IntegratedServerMixin from mod lithostitched,pl:mixin:A,pl:connector_pre_launch:A,pl:runtimedistcleaner:A}
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:707) ~[client-1.21.1-20240808.144430-srg.jar%23506!/:?] {re:mixin,pl:accesstransformer:B,pl:connector_pre_launch:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:connector_pre_launch:A}
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:267) ~[client-1.21.1-20240808.144430-srg.jar%23506!/:?] {re:mixin,pl:accesstransformer:B,pl:connector_pre_launch:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:connector_pre_launch:A}
	at java.base/java.lang.Thread.run(Thread.java:1583) [?:?] {re:mixin}

Multiplayer?

No

Version

1.21.1-0.8.1a (Latest 1.21.1)

Minecraft, Forge and maybe other related mods versions

NeoForge 21.1.250 Minecraft 1.21.1

Screenshots or Videos

No response

Crashlog/log

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions