Re: instance:list causes warning

2021-05-14 Thread Jean-Baptiste Onofre
Hi Steven,

Thanks for the update, I will try on a Windows VM.

Regards
JB

> Le 14 mai 2021 à 14:00, Steven Huypens  a écrit :
> 
> Hi Eric,
> 
> Thanks for testing. I tried the vanilla Karaf myself now. Downloaded it and 
> used start.bat to start Karaf. Then used client.bat to get the console and 
> executed "instance:list", then executed "log:display" to see the logging.
> 
> - On Windows 10 and Windows 8 I got the exceptionCaught-WARN
> - On Ubuntu there was no warning at all (used the shell scripts)
> 
> It's nog big deal for me, just wanted to let you know..
> 
> Best regards,
> Steven
> 
> On Thu, May 13, 2021 at 6:06 PM Eric Lilja  > wrote:
> I tried this with a vanilla Karaf 4.2.11 under Windows 10, using Cygwin as 
> shell. I've simply unpacked the zip file to the root of my main drive.
> 
> I started Karaf with the "karaf" shell script (not the .bat-file).
> 
> instance:list produced no warning in console itself or in the karaf.log file 
> under data/log
> 
> Unrelated, but FYI JB: However, I did see a weird warning when starting karaf 
> using the shell script, see below:
> 
> $ ./karaf
> : integer expression expected <---
> __ __  
>/ //_/ __ _/ __/
>   / ,<  / __ `/ ___/ __ `/ /_
>  / /| |/ /_/ / /  / /_/ / __/
> /_/ |_|\__,_/_/   \__,_/_/
> 
>   Apache Karaf (4.2.11)
> 
> Hit '' for a list of available commands
> and '[cmd] --help' for help on a specific command.
> Hit '' or type 'system:shutdown' or 'logout' to shutdown Karaf.
> 
> karaf@root()>
> 
> - Eric L
> 
> 
> On Wed, May 12, 2021 at 7:05 PM JB Onofré  > wrote:
> Hi
> 
> Forgot to check, sorry about that. I will keep you posted. 
> 
> Regards 
> JB
> 
>> Le 12 mai 2021 à 19:01, Steven Huypens > > a écrit :
>> 
>> 
>> Hi Jean-Baptiste,
>> 
>> Did you manage to reproduce this ?
>> 
>> Kind regards,
>> Steven
>> 
>> On Tue, May 4, 2021 at 2:10 PM Jean-Baptiste Onofre > > wrote:
>> Hi
>> 
>> Thanks for the update. Let me try to reproduce it. I keep you posted.
>> 
>> Regards
>> JB
>> 
>>> Le 4 mai 2021 à 14:07, Steven Huypens >> > a écrit :
>>> 
>>> Hi,
>>> 
>>> - etc/org.apache.karaf.shell.cfg is the default Karaf file
>>> - In etc/users.properties I had replaced the default Karaf user by my own 
>>> 'admin' with encrypted password. After reverting to the default 
>>> users.properties, and disabling encryption in org.apache.karaf.jaas.cfg, 
>>> the logline still appeared.
>>> 
>>> Best regards,
>>> Steven
>>> 
>>> On Tue, May 4, 2021 at 1:43 PM Jean-Baptiste Onofre >> > wrote:
>>> Hi,
>>> 
>>> What do you have in etc/org.apache.karaf.shell.cfg or etc/users.properties ?
>>> 
>>> Regards
>>> JB
>>> 
 Le 4 mai 2021 à 12:18, Steven Huypens >>> > a écrit :
 
 Hi,
 
 When executing the command "instance:list" on our custom Karaf 4.2.11 
 distro (based on 'standard'), we see the following warning in the logfile.
 
 2021-05-04 12:07:12,138 - 
 [o.a.s.s.s.ServerSessionImpl][sshd-SshServer[44db67ef](port=8101)-nio2-thread-2]
  WARN  - 
 exceptionCaught(ServerSessionImpl[null@/127.0.0.1:54060])[state=Opened] 
 IOException: De software op uw hostcomputer heeft een verbinding verbroken
 
 It looks like an shh-connection is being made with username 'null', which 
 obviously fails.
 
 This WARN is also logged when accessing the InstancesMBean, for instance 
 by the decanter-collector-jmx.This means we see the WARN regularly in our 
 logs.
 
 I would like to prevent this WARN-logline from being logged, but didn't 
 find a way to configure the default username, nor to disable the Mbean.
 
 Any suggestions ?
 
 Kind regards,
 Steven 
>>> 
>> 



InterruptedException being swallowed when looking up service

2021-05-14 Thread Kevin Schmidt
Hi,

I have a situation where a thread is started to perform a long running
task, but when a certain event occurs I want to interrupt and stop the
thread.  I use the standard Java technique to use Thread#interrupt on the
running thread, and in the thread be prepared to catch InterruptedException
and/or check the interrupt status on the thread.

This works fine in some cases, and not in others.  The difference has to do
with when the interrupt is raised and what code is executing at the time
that receives the interrupt.

One situation it does not work is if the interrupt is handled when the
thread is making a call to BundleContextImpl#getService, as
InterruptedException is not thrown nor is the interrupt flag set.  Instead,
a RuntimeException is thrown that wraps the InterruptedException.

While one can catch the RuntimeException and unwrap it looking to see if an
InterruptedException is present, that feels awkward and doesn't seem to
follow what appears to be the standard approach of throwing the exception
and/or setting the interrupt flag.

I'm using Karaf 4.2.9 and here is the stack trace:

java.lang.RuntimeException: java.lang.InterruptedException
at
org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:369)
at org.apache.felix.framework.Felix.getService(Felix.java:3737)
at
org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:470)
...
Caused by: java.lang.InterruptedException
at
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1302)
at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231)
at
org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:365)

Looking at the code, it does definitely just catch and wrap
InterruptedException, and does not set the interrupt flag again.

This feels like a bug to me, that InterruptedException should be thrown or
the interrupt flag should be set, so callers can be alerted to the
interrupt in a standard way and not have to know to catch and unwrap
RuntimeException.

I have not tried the latest Karaf, but reviewing the code in the latest
Felix it has changed and I'm actually not entirely sure what the behavior
will be in this scenario, I will try to test it out.

If this is a question for the Felix list since this is in that framework
code, please let me know and I take the discussion there.

Thanks,

Kevin


Re: instance:list causes warning

2021-05-14 Thread Steven Huypens
Hi Eric,

Thanks for testing. I tried the vanilla Karaf myself now. Downloaded it and
used start.bat to start Karaf. Then used client.bat to get the console and
executed "instance:list", then executed "log:display" to see the logging.

- On Windows 10 and Windows 8 I got the *exceptionCaught-*WARN
- On Ubuntu there was no warning at all (used the shell scripts)

It's nog big deal for me, just wanted to let you know..

Best regards,
Steven

On Thu, May 13, 2021 at 6:06 PM Eric Lilja  wrote:

> I tried this with a vanilla Karaf 4.2.11 under Windows 10, using Cygwin as
> shell. I've simply unpacked the zip file to the root of my main drive.
>
> I started Karaf with the "karaf" shell script (not the .bat-file).
>
> instance:list produced no warning in console itself or in the karaf.log
> file under data/log
>
> Unrelated, but FYI JB: However, I did see a weird warning when starting
> karaf using the shell script, see below:
>
> $ ./karaf
> : integer expression expected <---
> __ __  
>/ //_/ __ _/ __/
>   / ,<  / __ `/ ___/ __ `/ /_
>  / /| |/ /_/ / /  / /_/ / __/
> /_/ |_|\__,_/_/   \__,_/_/
>
>   Apache Karaf (4.2.11)
>
> Hit '' for a list of available commands
> and '[cmd] --help' for help on a specific command.
> Hit '' or type 'system:shutdown' or 'logout' to shutdown Karaf.
>
> karaf@root()>
>
> - Eric L
>
>
> On Wed, May 12, 2021 at 7:05 PM JB Onofré  wrote:
>
>> Hi
>>
>> Forgot to check, sorry about that. I will keep you posted.
>>
>> Regards
>> JB
>>
>> Le 12 mai 2021 à 19:01, Steven Huypens  a
>> écrit :
>>
>> 
>> Hi Jean-Baptiste,
>>
>> Did you manage to reproduce this ?
>>
>> Kind regards,
>> Steven
>>
>> On Tue, May 4, 2021 at 2:10 PM Jean-Baptiste Onofre 
>> wrote:
>>
>>> Hi
>>>
>>> Thanks for the update. Let me try to reproduce it. I keep you posted.
>>>
>>> Regards
>>> JB
>>>
>>> Le 4 mai 2021 à 14:07, Steven Huypens  a
>>> écrit :
>>>
>>> Hi,
>>>
>>> - etc/org.apache.karaf.shell.cfg is the default Karaf file
>>> - In etc/users.properties I had replaced the default Karaf user by my
>>> own 'admin' with encrypted password. After reverting to the default
>>> users.properties, and disabling encryption in org.apache.karaf.jaas.cfg,
>>> the logline still appeared.
>>>
>>> Best regards,
>>> Steven
>>>
>>> On Tue, May 4, 2021 at 1:43 PM Jean-Baptiste Onofre 
>>> wrote:
>>>
 Hi,

 What do you have in etc/org.apache.karaf.shell.cfg or
 etc/users.properties ?

 Regards
 JB

 Le 4 mai 2021 à 12:18, Steven Huypens  a
 écrit :

 Hi,

 When executing the command "instance:list" on our custom Karaf 4.2.11
 distro (based on 'standard'), we see the following warning in the logfile.

 *2021-05-04 12:07:12,138 -
 [o.a.s.s.s.ServerSessionImpl][sshd-SshServer[44db67ef](port=8101)-nio2-thread-2]
 WARN  -
 exceptionCaught(ServerSessionImpl[null@/127.0.0.1:54060])[state=Opened]
 IOException: De software op uw hostcomputer heeft een verbinding verbroken*

 It looks like an shh-connection is being made with username 'null',
 which obviously fails.

 This WARN is also logged when accessing the InstancesMBean, for
 instance by the decanter-collector-jmx.This means we see the WARN regularly
 in our logs.

 I would like to prevent this WARN-logline from being logged, but didn't
 find a way to configure the default username, nor to disable the Mbean.

 Any suggestions ?

 Kind regards,
 Steven



>>>