Bug 1395709 - require-bundle directives in OSGi metadata are not strict enough
Summary: require-bundle directives in OSGi metadata are not strict enough
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Software Collections
Classification: Red Hat
Component: lucene
Version: rh-java-common
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Michael Simacek
QA Contact: Lukáš Zachar
URL:
Whiteboard:
Depends On:
Blocks: 1389302 1397483
TreeView+ depends on / blocked
 
Reported: 2016-11-16 13:44 UTC by Mat Booth
Modified: 2017-04-26 09:30 UTC (History)
10 users (show)

Fixed In Version: rh-java-common-lucene-4.8.0-6.8.el6 rh-java-common-lucene-4.8.0-6.8.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1397483 (view as bug list)
Environment:
Last Closed: 2017-04-26 09:30:42 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Proposed Patch (2.48 KB, patch)
2016-11-16 13:47 UTC, Mat Booth
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:1152 0 normal SHIPPED_LIVE rh-java-common bug fix and enhancement update 2017-04-26 13:29:19 UTC

Description Mat Booth 2016-11-16 13:44:26 UTC
Description of problem:

It is currently impossible to have both lucene 4 and lucene 5 in the same OSGi runtime, due to the require-bundle directives being too relaxed in lucene 4. For example, I am seeing java.lang.VerifyErrors in Eclipse when I try this. Here is an example of such an error:

Exception Details:
  Location:
    org/eclipse/epp/internal/logging/aeri/ide/server/mars/ServerProblemsHistory.createInitialIndex(Lorg/apache/lucene/store/Directory;)V @14: invokespecial
  Reason:
    Type 'org/apache/lucene/analysis/core/KeywordAnalyzer' (current frame, stack[3]) is not assignable to 'org/apache/lucene/analysis/Analyzer'
  Current Frame:
    bci: @14
    flags: { }
    locals: { 'org/eclipse/epp/internal/logging/aeri/ide/server/mars/ServerProblemsHistory', 'org/apache/lucene/store/Directory' }
    stack: { uninitialized 0, uninitialized 0, 'org/apache/lucene/util/Version', 'org/apache/lucene/analysis/core/KeywordAnalyzer' }
  Bytecode:
    0x0000000: bb00 6959 b200 6bbb 0071 59b7 0073 b700
    0x0000010: 744d 2cb2 0077 b600 7d57 014e 013a 04bb
    0x0000020: 0081 592b 2cb7 0083 3a05 bb00 8659 b700
    0x0000030: 883a 0619 06bb 0089 5912 0812 0bb2 008b
    0x0000040: b200 91b7 0097 b600 9a19 0519 06b6 009e
    0x0000050: 1905 b600 a219 05c6 0032 1905 b600 a5a7
    0x0000060: 002a 4e19 05c6 0008 1905 b600 a52d bf3a
    0x0000070: 042d c700 0919 044e a700 0f2d 1904 a500
    0x0000080: 092d 1904 b600 a82d bfb1               
  Exception Handler Table:
    bci [42, 85] => handler: 98
    bci [31, 111] => handler: 111
  Stackmap Table:
    full_frame(@98,{Object[#1],Object[#180],Object[#105],Object[#169],Object[#169],Object[#129]},{Object[#169]})
    chop_frame(@109,1)
    same_locals_1_stack_item_frame(@111,Object[#169])
    same_frame(@123)
    same_frame(@135)
    chop_frame(@137,2)

The problem is that the OSGi runtime is not wiring the expected version of lucene.core as a dependency of lucene.analysis. When you debug the OSGi runtime, you can see that it wires the newest possible version of org.apache.lucene.core as a dependency of org.apache.lucene.analysis_4.8.0

Requirement: osgi.wiring.bundle; filter:="(&(osgi.wiring.bundle=org.apache.lucene.core)(bundle-version>=4.8.0))"
Provider:    osgi.identity; osgi.identity="org.apache.lucene.core"; type="osgi.bundle"; version:Version="5.4.1"

While this is correct from an OSGi POV, it's this Lucene version mis-match that causes the above java.lang.VerifyError

When I fix the OSGi metadata in lucene 4 to make the require-bundle directive more strict, this error goes away and OSGi wires the dependencies as expected.

Comment 1 Mat Booth 2016-11-16 13:47:08 UTC
Created attachment 1221155 [details]
Proposed Patch

Comment 2 Mat Booth 2016-11-16 13:51:15 UTC
(In reply to Mat Booth from comment #1)
> Created attachment 1221155 [details]
> Proposed Patch

With this patch applied, debugging the runtime now shows the correct wiring:

Requirement: osgi.wiring.bundle; filter:="(&(osgi.wiring.bundle=org.apache.lucene.core)(&(bundle-version>=4.8.0)(!(bundle-version>=5.0.0))))"
Provider:    osgi.identity; osgi.identity="org.apache.lucene.core"; type="osgi.bundle"; version:Version="4.8.0"

Comment 15 errata-xmlrpc 2017-04-26 09:30:42 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:1152


Note You need to log in before you can comment on or make changes to this bug.