Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switches removed from Voltage Level local data structures before call to Network listeners #2016

Closed
zamarrenolm opened this issue Mar 16, 2022 · 0 comments · Fixed by #2022
Closed
Assignees

Comments

@zamarrenolm
Copy link
Member

  • Do you want to request a feature or report a bug?
    Bug

  • What is the current behavior?
    Switches are removed from Voltage Level data structures before the Network listeners are notified through the method beforeRemoval. Switches are still in the Network index, but queries to gather information about the switch from beforeRemoval methods made to the voltage level fail because they have been removed from local switches collection and its corresponding edges also have been removed from the graph.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
    Unit test to demonstrate the issue (fails with exception trying to obtain end nodes of a switch inside a beforeRemoval method):

public class RemoveSwitchTest {

    private static void checkNodes(Switch sw) {
        int node1 = sw.getVoltageLevel().getNodeBreakerView().getNode1(sw.getId());
        int node2 = sw.getVoltageLevel().getNodeBreakerView().getNode1(sw.getId());
        assertTrue(node1 >= 0);
        assertTrue(node2 >= 0);
    }

    @Test
    public void nodeBreakerTest() {
        Network network = NetworkTest1Factory.create();
        Switch sw = network.getSwitch("load1Breaker1");
        checkNodes(sw);
        network.addListener(new DefaultNetworkListener() {
            @Override
            public void beforeRemoval(Identifiable identifiable) {
                if (identifiable instanceof Switch) {
                    checkNodes((Switch) identifiable);
                }
            }
        });
        sw.getVoltageLevel().getNodeBreakerView().removeSwitch(sw.getId());
    }
}

The stack trace of the error:

ERROR com.powsybl.iidm.network.impl.NetworkListenerList - com.powsybl.commons.PowsyblException: Switch load1Breaker1 not found
com.powsybl.commons.PowsyblException: Switch load1Breaker1 not found
	at com.powsybl.iidm.network.impl.NodeBreakerVoltageLevel.createSwitchNotFoundException(NodeBreakerVoltageLevel.java:591)
	at com.powsybl.iidm.network.impl.NodeBreakerVoltageLevel.getEdge(NodeBreakerVoltageLevel.java:569)
	at com.powsybl.iidm.network.impl.NodeBreakerVoltageLevel$2.getNode1(NodeBreakerVoltageLevel.java:624)
	at com.powsybl.iidm.network.impl.RemoveSwitchTest.checkNodes(RemoveSwitchTest.java:15)
	at com.powsybl.iidm.network.impl.RemoveSwitchTest$1.beforeRemoval(RemoveSwitchTest.java:29)
  • What is the expected behavior?
    Be able to obtain the nodes of the switch before it is removed.

  • Please tell us about your environment:

    • PowSyBl Version: 4.8.0-SNAPSHOT
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, spectrum, etc)
    A similar issue happens in BusBreakerVoltageLevel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant