tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TOMEE-2087) IvmContext.list() does not correctly list the context content
Date Fri, 14 Jul 2017 13:36:00 GMT

    [ https://issues.apache.org/jira/browse/TOMEE-2087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16087321#comment-16087321
] 

ASF GitHub Bot commented on TOMEE-2087:
---------------------------------------

Github user otaviojava commented on a diff in the pull request:

    https://github.com/apache/tomee/pull/88#discussion_r127457343
  
    --- Diff: arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/naming/NamingBean.java
---
    @@ -0,0 +1,136 @@
    +/*
    + * 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.openejb.arquillian.tests.naming;
    +
    +import org.apache.openejb.core.interceptor.Interceptor;
    +import org.apache.openejb.core.ivm.naming.SystemComponentReference;
    +
    +import javax.ejb.LocalBean;
    +import javax.ejb.Stateless;
    +import javax.naming.*;
    +import java.io.ByteArrayOutputStream;
    +import java.io.PrintWriter;
    +import java.io.UnsupportedEncodingException;
    +import java.nio.charset.StandardCharsets;
    +import java.util.HashMap;
    +import java.util.Map;
    +
    +@Stateless
    +@LocalBean
    +public class NamingBean {
    +    private interface ListOperation {
    +        NamingEnumeration<? extends NameClassPair> execute(Context context, String
address) throws NamingException;
    +    }
    +
    +    public void verifyContextList() throws NamingException {
    +        verifyContextListInternal(new ListOperation() {
    +            @Override
    +            public NamingEnumeration<NameClassPair> execute(Context context, String
address) throws NamingException {
    +                return context.list(address);
    +            }
    +        });
    +    }
    +
    +    public void verifyContextListBindings() throws NamingException {
    +        verifyContextListInternal(new ListOperation() {
    +            @Override
    +            public NamingEnumeration<Binding> execute(Context context, String address)
throws NamingException {
    +                return context.listBindings(address);
    +            }
    +        });
    +    }
    +
    +    private void verifyContextListInternal(ListOperation listOperation) throws NamingException
{
    +        final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    +        final PrintWriter logSink = new PrintWriter(buffer);
    +
    +        final InitialContext ctx = new InitialContext();
    +        final boolean hasErrors = listContext(ctx, "", listOperation, logSink);
    +        logSink.flush();
    +
    +        if (hasErrors) {
    +            throw new IllegalStateException("Failed to lookup some of the listed entries:\n"
+ getPrintedJndiTree(buffer));
    +        }
    +    }
    +
    +    private String getPrintedJndiTree(ByteArrayOutputStream buffer) {
    +        try {
    +            return buffer.toString("utf-8");
    --- End diff --
    
    Maybe a constant.
    :warning: `buffer.toString(StandardCharsets.UTF_8.name());`
    
    https://docs.oracle.com/javase/7/docs/api/java/nio/charset/StandardCharsets.html#UTF_8


> IvmContext.list() does not correctly list the context content
> -------------------------------------------------------------
>
>                 Key: TOMEE-2087
>                 URL: https://issues.apache.org/jira/browse/TOMEE-2087
>             Project: TomEE
>          Issue Type: Bug
>            Reporter: Svetlin Zarev
>            Priority: Critical
>         Attachments: sample.zip
>
>
> MyNamingEnumeration.gatherNodes() adds the wrong federated context entries in the result
set (related to TOMEE-2086 - it was indeed a typo, but we "fixed" it with the wrong NameNode).
> Another issue is with MyNamingEnumeration.isMyChild() which considers entries that are
NOT children to the "parent" tree as such
> One more issue is that the wrong parentNode is passed as argument to gatherNodes in case
we are listing the context for any "IvmContext != this"
> To give an example:
> Expected context content:
> {code}
> ### Context: /module
> Name: TestEJB!org.example.TestEJB	Class=org.apache.openejb.assembler.classic.JndiBuilder$ContextualEjbLookup
[looking up: TestEJB!org.example.TestEJB]	[Value]: proxy=org.example.TestEJB;deployment=ROOT//TestEJB;pk=null
> Name: TestEJB	Class=org.apache.openejb.assembler.classic.JndiBuilder$ContextualEjbLookup
[looking up: TestEJB]	[Value]: proxy=org.example.TestEJB;deployment=ROOT//TestEJB;pk=null
> Name: ModuleName	Class=java.lang.String	[looking up: ModuleName]	[Value]: 
> Name: env	Class=org.apache.naming.NamingContext	[looking up: env]	[Value]: org.apache.naming.NamingContext@1bb2d0a8
> ### Context: /module/env
> Name: name	Class=java.lang.String	[looking up: name]	[Value]: module-env
> {code} 
> Actual context content:
> {code}
> ### Context: /module
> Name: global	Class=org.apache.openejb.core.ivm.naming.IvmContext	[looking up: global]
> Failed to lookup: global
> Name: dummy	Class=java.lang.String	[looking up: dummy]	> Failed to lookup: dummy
> Name: TestEJB!org.example.TestEJB	Class=org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference
[looking up: TestEJB!org.example.TestEJB]	[Reference]: proxy=org.example.TestEJB;deployment=ROOT//TestEJB;pk=null
> Name: TestEJB	Class=org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference	[looking
up: TestEJB]	[Reference]: proxy=org.example.TestEJB;deployment=ROOT//TestEJB;pk=null
> Name: ModuleName	Class=java.lang.String	[looking up: ModuleName]	[Value]: 
> Name: env	Class=org.apache.openejb.core.ivm.naming.IvmContext	[looking up: env]	[Value]:
IvmContext{mynode=}
> Name: TestEJB!org.example.TestEJB	Class=org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference
[looking up: TestEJB!org.example.TestEJB]	[Reference]: proxy=org.example.TestEJB;deployment=ROOT//TestEJB;pk=null
> Name: TestEJB	Class=org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference	[looking
up: TestEJB]	[Reference]: proxy=org.example.TestEJB;deployment=ROOT//TestEJB;pk=null
> ### Context: /module/env
> Name: TestEJB!org.example.TestEJB	Class=org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference
[looking up: TestEJB!org.example.TestEJB]	> Failed to lookup: TestEJB!org.example.TestEJB
> Name: TestEJB	Class=org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference	[looking
up: TestEJB]	> Failed to lookup: TestEJB
> Name: name	Class=java.lang.String	[looking up: name]	[Value]: module-env
> {code}
> Note the "failed too lookup..." messages - these are all objects that MUST NOT be listed
as part of that context.
> I'm attaching an application that reproduces the issue. 
> Requesting it like "http://localhost:8080/?ejb" will print tomee's naming tree
> Requesting it like "http://localhost:8080" will print tomcat's naming tree



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message