-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoids IllegalArgumentException on unget
fixes https://issues.apache.org/jira/browse/FELIX-6726 ungetServiceObject may be called twice in some cases, which causes an IllegalArgumentException to be thrown and logged. Signed-off-by: Juergen Albert <[email protected]>
- Loading branch information
1 parent
396de83
commit a623362
Showing
9 changed files
with
236 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
scr/src/test/java/org/apache/felix/scr/integration/Felix6726Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.felix.scr.integration; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.apache.felix.scr.integration.components.felix6726.Consumer; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.ops4j.pax.exam.junit.PaxExam; | ||
import org.osgi.framework.BundleContext; | ||
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO; | ||
|
||
/** | ||
* This test validates the FELIX-6726 issue. | ||
*/ | ||
@RunWith(PaxExam.class) | ||
public class Felix6726Test extends ComponentTestBase | ||
{ | ||
static | ||
{ | ||
// uncomment to enable debugging of this test class | ||
// paxRunnerVmOption = DEBUG_VM_OPTION; | ||
descriptorFile = "/integration_test_FELIX_6726.xml"; | ||
COMPONENT_PACKAGE = COMPONENT_PACKAGE + ".felix6726"; | ||
restrictedLogging = false; | ||
//comment to get debug logging if the test fails. | ||
DS_LOGLEVEL = "debug"; | ||
//paxRunnerVmOption = DEBUG_VM_OPTION; | ||
} | ||
|
||
@Inject | ||
protected BundleContext bundleContext; | ||
|
||
protected static void delay(int secs) | ||
{ | ||
try | ||
{ | ||
Thread.sleep(secs * 1000); | ||
} | ||
catch (InterruptedException ie) | ||
{ | ||
} | ||
} | ||
|
||
/** | ||
* This Test actually never fails, but it will provoke the {@link IllegalStateException} to be logged by SCR | ||
*/ | ||
@Test | ||
public void test_IllegalStateExceptionLogging() | ||
{ | ||
final ComponentConfigurationDTO bImplDTO = findComponentConfigurationByName("felix.6726.B", 4); | ||
final ComponentConfigurationDTO consumerDTO = findComponentConfigurationByName( "felix.6726.Consumer", 4); | ||
|
||
Consumer consumer = getServiceFromConfiguration(consumerDTO, Consumer.class); | ||
try { | ||
ungetServiceFromConfiguration(consumerDTO, Consumer.class); | ||
} catch (IllegalStateException e) { | ||
fail(); | ||
} | ||
|
||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
scr/src/test/java/org/apache/felix/scr/integration/components/felix6726/A.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.felix.scr.integration.components.felix6726; | ||
|
||
public interface A { | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
scr/src/test/java/org/apache/felix/scr/integration/components/felix6726/B.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.felix.scr.integration.components.felix6726; | ||
|
||
public interface B extends A { | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
scr/src/test/java/org/apache/felix/scr/integration/components/felix6726/BImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.felix.scr.integration.components.felix6726; | ||
|
||
public class BImpl implements B | ||
{ | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
scr/src/test/java/org/apache/felix/scr/integration/components/felix6726/Consumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.felix.scr.integration.components.felix6726; | ||
|
||
public class Consumer { | ||
|
||
A reference; | ||
|
||
public void activate() { | ||
System.out.println("Hallo World"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
<components> | ||
<scr:component name="felix.6726.B" | ||
xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" | ||
enabled="true"> | ||
<implementation class="org.apache.felix.scr.integration.components.felix6726.BImpl" /> | ||
<service scope="prototype"> | ||
<provide interface="org.apache.felix.scr.integration.components.felix6726.B" /> | ||
<provide interface="org.apache.felix.scr.integration.components.felix6726.A" /> | ||
</service> | ||
</scr:component> | ||
|
||
<scr:component name="felix.6726.Consumer" | ||
xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" | ||
activate="activate" | ||
enabled="true"> | ||
<implementation class="org.apache.felix.scr.integration.components.felix6726.Consumer" /> | ||
<service scope="prototype"> | ||
<provide interface="org.apache.felix.scr.integration.components.felix6726.Consumer" /> | ||
</service> | ||
<reference name="reference" | ||
interface="org.apache.felix.scr.integration.components.felix6726.A" | ||
scope="prototype_required" | ||
field="reference"/> | ||
</scr:component> | ||
</components> |