This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 255917
Collapse All | Expand All

(-)a/extexecution.base/apichanges.xml (+15 lines)
Lines 110-115 Link Here
110
    <!-- ACTUAL CHANGES BEGIN HERE: -->
110
    <!-- ACTUAL CHANGES BEGIN HERE: -->
111
111
112
    <changes>
112
    <changes>
113
        <change>
114
            <api name="extexecution_base_spi"/>
115
            <summary>Advice to throw UnsupportedOperationException</summary>
116
            <version major="1" minor="4"/>
117
            <date day="21" month="10" year="2015"/>
118
            <author login="phejl"/>
119
            <compatibility addition="yes"/>
120
            <description>
121
                Document that ProcessesImplementation may throw
122
                an UnsupportedOperationException when it is not able to kill
123
                the process tree.
124
            </description>
125
            <class package="org.netbeans.spi.extexecution.base" name="ProcessesImplementation"/>
126
            <issue number="255917"/>
127
        </change>
113
128
114
        <change>
129
        <change>
115
            <api name="extexecution_base_api"/>
130
            <api name="extexecution_base_api"/>
(-)a/extexecution.base/manifest.mf (-1 / +1 lines)
Lines 2-7 Link Here
2
AutoUpdate-Show-In-Client: false
2
AutoUpdate-Show-In-Client: false
3
OpenIDE-Module: org.netbeans.modules.extexecution.base/2
3
OpenIDE-Module: org.netbeans.modules.extexecution.base/2
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/extexecution/base/resources/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/extexecution/base/resources/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.3
5
OpenIDE-Module-Specification-Version: 1.4
6
OpenIDE-Module-Recommends: org.netbeans.spi.extexecution.base.ProcessesImplementation
6
OpenIDE-Module-Recommends: org.netbeans.spi.extexecution.base.ProcessesImplementation
7
7
(-)a/extexecution.base/src/org/netbeans/api/extexecution/base/Processes.java (-1 / +1 lines)
Lines 73-79 Link Here
73
     *
73
     *
74
     * @param process process to kill
74
     * @param process process to kill
75
     * @param environment map containing the variables and their values which the
75
     * @param environment map containing the variables and their values which the
76
     *             process must have to be considered being part of
76
     *             process should have to be considered being part of
77
     *             the tree to kill; used as a hint to find subprocesses
77
     *             the tree to kill; used as a hint to find subprocesses
78
     */
78
     */
79
    public static void killTree(Process process, Map<String, String> environment) {
79
    public static void killTree(Process process, Map<String, String> environment) {
(-)a/extexecution.base/src/org/netbeans/spi/extexecution/base/ProcessesImplementation.java (-3 / +5 lines)
Lines 67-74 Link Here
67
     *
67
     *
68
     * @param process process to kill
68
     * @param process process to kill
69
     * @param environment map containing the variables and their values which the
69
     * @param environment map containing the variables and their values which the
70
     *             process must have to be considered being part of
70
     *             process should have to be considered being part of
71
     *             the tree to kill
71
     *             the tree to kill; used as a hint to find subprocesses
72
     * @throws UnsupportedOperationException when this implementation is not able
73
     *             to even attempt to kill the process and the subprocesses
72
     */
74
     */
73
    void killTree(Process process, Map<String, String> environment);
75
    void killTree(Process process, Map<String, String> environment) throws UnsupportedOperationException;
74
}
76
}
(-)a/extexecution.base/test/unit/src/org/netbeans/api/extexecution/base/ProcessesTest.java (-1 / +41 lines)
Lines 44-50 Link Here
44
44
45
import java.io.InputStream;
45
import java.io.InputStream;
46
import java.io.OutputStream;
46
import java.io.OutputStream;
47
import java.util.Collection;
47
import java.util.HashMap;
48
import java.util.HashMap;
49
import java.util.Iterator;
48
import java.util.Map;
50
import java.util.Map;
49
import org.netbeans.junit.NbTestCase;
51
import org.netbeans.junit.NbTestCase;
50
import org.netbeans.spi.extexecution.base.ProcessesImplementation;
52
import org.netbeans.spi.extexecution.base.ProcessesImplementation;
Lines 65-71 Link Here
65
    protected void setUp() throws Exception {
67
    protected void setUp() throws Exception {
66
        super.setUp();
68
        super.setUp();
67
69
68
        MockLookup.setInstances(new TestProcessesImplementation());
70
        MockLookup.setInstances(new TestProcessesImplementation(), new TestProcessesImplementation());
69
    }
71
    }
70
72
71
    public void testKillTree() {
73
    public void testKillTree() {
Lines 89-94 Link Here
89
        assertEquals(env.get("test2"), perfEnv.get("test2"));
91
        assertEquals(env.get("test2"), perfEnv.get("test2"));
90
    }
92
    }
91
93
94
    public void testAnotherImplementation() {
95
        TestProcess process = new TestProcess();
96
        Map<String, String> env = new HashMap<String, String>();
97
        env.put("test1", "value1");
98
        env.put("test2", "value2");
99
100
        ProcessesImplementation impl = Lookup.getDefault().lookup(ProcessesImplementation.class);
101
        assertNotNull(impl);
102
103
        TestProcessesImplementation testPerformer = (TestProcessesImplementation) impl;
104
        testPerformer.setEnabled(false);
105
106
        Processes.killTree(process, env);
107
108
        Collection<? extends ProcessesImplementation> impls = Lookup.getDefault().lookupAll(ProcessesImplementation.class);
109
        assertEquals(2, impls.size());
110
111
        Iterator<? extends ProcessesImplementation> it = impls.iterator();
112
        it.next();
113
        testPerformer = (TestProcessesImplementation) it.next();
114
        assertEquals(process, testPerformer.getProcess());
115
116
        Map<String, String> perfEnv = testPerformer.getEnv();
117
        assertEquals(2, perfEnv.size());
118
119
        assertEquals(env.get("test1"), perfEnv.get("test1"));
120
        assertEquals(env.get("test2"), perfEnv.get("test2"));
121
    }
122
92
    private static class TestProcess extends Process {
123
    private static class TestProcess extends Process {
93
124
94
        private boolean destroyed;
125
        private boolean destroyed;
Lines 131-142 Link Here
131
162
132
    private static class TestProcessesImplementation implements ProcessesImplementation {
163
    private static class TestProcessesImplementation implements ProcessesImplementation {
133
164
165
        private boolean enabled = true;
166
134
        private Process process;
167
        private Process process;
135
168
136
        private Map<String, String> env;
169
        private Map<String, String> env;
137
170
138
        @Override
171
        @Override
139
        public void killTree(Process process, Map<String, String> environment) {
172
        public void killTree(Process process, Map<String, String> environment) {
173
            if (!enabled) {
174
                throw new UnsupportedOperationException("Not enabled");
175
            }
140
            this.process = process;
176
            this.process = process;
141
            this.env = environment;
177
            this.env = environment;
142
        }
178
        }
Lines 148-152 Link Here
148
        public Map<String, String> getEnv() {
184
        public Map<String, String> getEnv() {
149
            return env;
185
            return env;
150
        }
186
        }
187
188
        public void setEnabled(boolean enabled) {
189
            this.enabled = enabled;
190
        }
151
    }
191
    }
152
}
192
}

Return to bug 255917