hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
190 stars 98 forks source link

JAXRSConnector compares integer with string port values #192

Open t-mazgalov opened 6 years ago

t-mazgalov commented 6 years ago

The JAXRSConnector checks if the ports of the HTTP Service implementation and the registered resource are equal. In some cases, the value of HTTP Service port is Integer and the check fails.

I'm using the Equinox HTTP Service implementation which registers

{org.osgi.service.http.HttpService}={http.port=80, service.pid=org.eclipse.equinox.http.HttpService-http, http.address=ALL, service.vendor=IBM, service.description=OSGi Http Service - IBM Implementation, http.scheme=http, http.timeout=30, service.id=106, service.bundleid=91, service.scope=bundle}

  private HttpService findHttpServiceForPort( Object port ) {
    ServiceHolder[] serviceHolders = httpServices.getServices();
    HttpService result = null;
    for( ServiceHolder serviceHolder : serviceHolders ) {
      Object servicePort = getPort( serviceHolder );
      // servicePort is Integer
      // port is String
      if( servicePort.equals( port ) ) {
        result = ( HttpService )serviceHolder.getService();
      }
    }
    return result;
  }
t-mazgalov commented 6 years ago

Pull request opened https://github.com/hstaudacher/osgi-jax-rs-connector/pull/193