Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1395709

Summary: require-bundle directives in OSGi metadata are not strict enough
Product: Red Hat Software Collections Reporter: Mat Booth <mat.booth>
Component: luceneAssignee: Michael Simacek <msimacek>
Status: CLOSED ERRATA QA Contact: Lukáš Zachar <lzachar>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rh-java-commonCC: bgollahe, jkejda, jorton, kanderso, mbenitez, mizdebsk, msimacek, qe-baseos-apps, sgehwolf, vkadlcik
Target Milestone: ---Keywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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:
Story Points: ---
Clone Of:
: 1397483 (view as bug list) Environment:
Last Closed: 2017-04-26 09:30:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1389302, 1397483    
Attachments:
Description Flags
Proposed Patch none

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