Tommy Tynjä | 30 Sep 09:26 2014
Picon

[beanutils] Precision lost when converting BigDecimal

Hi.

I'm using commons-beanutils in my current project for bean copy operations. I have a use case where I would like to convert a domain specific object which extends BigDecimal to a regular java.math.BigDecimal. If my domain specific object contains decimals, precision is lost at time of conversion. A BigDecimal of e.g. value 3200.11 will be converted to a BigDecimal with value 3200. This happens due to org.apache.commons.beanutils.converters.NumberConverter does a BigDecimal.valueOf(value.longValue()) at line 375 (current trunk). I've created a reproducing test case which demonstrates the behavior (please see the attached TestCase_ExtendingBigDecimal.patch file).

Is this a bug or how am I expected to handle this use case?

Adding the following code (please see attached NumberConverter.patch file) before executing "else { return targetType.cast(BigDecimal.valueOf(value.longValue())); }" in NumberConverter seems to fix this issue (and all project test cases pass):
} else if (value instanceof BigDecimal) {
return targetType.cast(value);
}

Best regards
Tommy Tynjä


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe <at> commons.apache.org
For additional commands, e-mail: user-help <at> commons.apache.org
BEROUD Louis | 25 Sep 18:44 2014

[imaging] Creating Tiff from TiffImageMetadata and raw pixel data

Hello,

 

I would like to construct a TIFF file from a pixel data array.

I have successfully created a TiffImageMetadata (from your library) with all needed fields but I can’t find the way to concat/add the pixel data and then write a TIFF file with it.

The byte array is a gray scale image and I have got some information about it (that I have put in the TiffImageMetadata).

Can you please help me with this sample issue ?

 

Kind regards / Cordialement

 

Louis BEROUD

Java / J2EE Developper

Tour Gallieni 2

36 Avenue du Général de Gaulle

93175 Bagnolet Cedex

FRANCE

Tel : +33 (0)1 48 97 59 65 (ext 53 37)

http://www.infotel.com

Please consider the environment - do you really need to print this email ?

 

Oliver Heger | 25 Sep 21:25 2014
Picon

[ANNOUNCEMENT] Commons Configuration 2.0-alpha1 Released

The Apache Commons Team is pleased to announce the availability of
Apache Commons Configuration 2.0-alpha1.

The Commons Configuration software library provides a generic
configuration interface which enables an application to read
configuration data from a variety of sources.

This is the first alpha release for version 2.0 of Commons
Configuration. Version 2 is a major redesign of the Configuration API.
It breaks compatibility in many areas and, therefore, is not a drop-in
replacement for Commons Configuration 1.x. The main purpose of this
alpha release is to gather feedback from the community about the
reworked API. IT IS NOT YET PRODUCTION READY. It is expected that there
will still be some changes on the public API.

A full list of all changes can be found in the release notes at
  http://www.apache.org/dist/commons/configuration/RELEASE-NOTES.txt

There is also an upgrade guide available for users of version 1.x at
  http://commons.apache.org/configuration/userguide/upgradeto2_0.html

Source and binary distributions are available for download from the
Apache Commons download site:

http://commons.apache.org/proper/commons-configuration/download_configuration.cgi

When downloading, please verify signatures using the KEYS file available
at the above location when downloading the release. (Note: Because this
is an alpha version, we decided that it will not be distributed to Maven
central.)

For complete information on Commons Configuration, including
instructions on how to submit bug reports, patches, or suggestions for
improvement, see the Apache Commons Configuration website:

http://commons.apache.org/proper/commons-configuration/

Oliver Heger, on behalf of the Apache Commons community
~ * ~ Srijith Unni ~ * ~ | 25 Sep 15:57 2014

Returning non-zero exit code in Windows

Hi All,

         I am making use of commons-daemon to get my java process started
as a Windows Service. I am installing the service and launching it in jvm
mode. I want to handle any error condition that occurs and I am returning a
non-zero exit code, and I have set Recovery Options for my service. However
I am not seeing the service being restarted. I have gone through
http://comments.gmane.org/gmane.comp.jakarta.commons.issues/19191 and
http://markmail.org/message/mkavfkirjqb37bqn and I see that this issue was
fixed long back in 1.0.11.

         What I am doing is having an UncaughtExceptionHandler for my Java
runtime and I am handling the same and doing a System.exit(-1). When I run
my service prunsrv.exe separately from command prompt I am seeing that the
exit code is -1, but somehow while running as a service, it is not working
as expected.

         Can you let me know what I am doing wrong / if I have missed
anything.

--

-- 
Thanks & Regards,
--
A.Srijith.K.Unni
Mail ID : srijith.unni <at> gmail.com
Home Page : https://about.me/srijith
bobrobertsonjr | 17 Sep 21:18 2014
Picon

Re: [compress] checksums differ for same tar file created twice

OK, I've written a test case and convinced myself it's a bug. Will submit a
patch.

--
View this message in context: http://apache-commons.680414.n4.nabble.com/compress-checksums-differ-for-same-tar-file-created-twice-tp4666906p4666946.html
Sent from the Commons - User mailing list archive at Nabble.com.
Anjib Mulepati | 13 Sep 21:58 2014
Picon

[net] Telnet program doesn't terminate with write()

Hi All,

I couldn't understand why this program doesn't terminate if I send 
command? If I don't send the command it does terminate. I am trying to 
understand the way to issue sequence of command in telnet server.

public class TelnetSample {
     private TelnetClient telnet = new TelnetClient();
       private InputStream in;
       private PrintStream out;
       private char prompt = '.';

       public TelnetSample( String server, String user, String password ) {
        try {
          // Connect to the specified server
          telnet.connect( server, 23 );

          // Get input and output stream references
          in = telnet.getInputStream();
          out = new PrintStream( telnet.getOutputStream() );

          // Advance to a prompt
         readUntil( prompt + " " );
        }
        catch( Exception e ) {
          e.printStackTrace();
        }
       }

        public String readUntil( String pattern ) {
        try {
          char lastChar = pattern.charAt( pattern.length() - 1 );
          StringBuffer sb = new StringBuffer();
          char ch = ( char )in.read();
          while( true ) {
           System.out.print( ch );
           sb.append( ch );
           if( ch == lastChar ) {
             if( sb.toString().endsWith( pattern ) ) {
              return sb.toString();
             }
           }
           ch = ( char )in.read();
          }
        }
        catch( Exception e ) {
          e.printStackTrace();
        }
        return null;
       }

       public void write( String value ) {
        try {
          out.println( value );
          out.flush();
          System.out.println( value );
        }
        catch( Exception e ) {
          e.printStackTrace();
        }
       }

       public String sendCommand( String command ) {
        try {
          write( command );
          return readUntil( prompt + " " );
        }
        catch( Exception e ) {
          e.printStackTrace();
        }
        return null;
       }

       public void disconnect() {
        try {
          telnet.disconnect();
        }
        catch( Exception e ) {
          e.printStackTrace();
        }
       }

       public static void main( String[] args ) {
        try {
          TelnetSample telnet = new TelnetSample( "telehack.com",
                              "username",
                              "password" );
          telnet.sendCommand( "date" );
          telnet.disconnect();
          System.out.println("Disconnected");
        }
        catch( Exception e ) {
          e.printStackTrace();
        }
       }

}
Nick Watts | 11 Sep 21:37 2014
Picon

[configuration] JXPathException when setting the default expression engine

Hello, I've run into a problem that looks to me like a bug. I thought I'd
get some input on it first though.

Here are two JUnit test cases that both pass with Commons Config 1.10:

import static org.junit.Assert.*;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationBuilder;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.configuration.tree.DefaultExpressionEngine;
import org.apache.commons.configuration.tree.xpath.XPathExpressionEngine;
import org.apache.commons.jxpath.JXPathException;
import org.junit.Before;

public class Test {

     <at> Before
    public void before() {
        HierarchicalConfiguration.setDefaultExpressionEngine(new
DefaultExpressionEngine());
    }

     <at> org.junit.Test
    public void testSetExpressionEngineAfterLoad() throws
ConfigurationException {
        ConfigurationBuilder builder = new
DefaultConfigurationBuilder("configuration_builder.xml");
        ((XMLConfiguration)builder).setBasePath("src/test/resources/");
        Configuration config = builder.getConfiguration();
        HierarchicalConfiguration.setDefaultExpressionEngine(new
XPathExpressionEngine());
        assertEquals("mail.test.org", config.getString("mail/host"));
        assertEquals("root <at> test.org", config.getString("mail/from"));
        assertEquals("otheruser <at> test.org", config.getString("mail/to"));
        assertEquals("thatguy <at> test.org", config.getString("mail/cc"));
        assertEquals("", config.getString("mail/bcc"));
    }

     <at> org.junit.Test(expected=JXPathException.class)
    public void testSetExpressionEngineBeforeLoad() {
        try {
            HierarchicalConfiguration.setDefaultExpressionEngine(new
XPathExpressionEngine());
            ConfigurationBuilder builder = new
DefaultConfigurationBuilder("configuration_builder.xml");
            ((XMLConfiguration)builder).setBasePath("src/test/resources/");
            builder.getConfiguration();
        } catch (ConfigurationException e) {
            e.printStackTrace();
        }
    }
}

The configuration_builder.xml file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<configuration>
    <override>
        <xml fileName="dev.config.xml" config-name="env-config" />
        <xml fileName="config.xml" config-name="default-config" />
    </override>
</configuration>

the config.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <mail>
        <host>mail.test.org</host>
        <from>root <at> test.org</from>
        <to>nwatts <at> test.org</to>
        <cc/>
        <bcc/>
    </mail>
</config>

the dev.config.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <mail>
        <to>otheruser <at> test.org</to>
        <cc>thatguy <at> test.org</cc>
    </mail>
 </config>

The possible bug is that the call to
HierarchicalConfiguration.setDefaultExpressionEngine(new
XPathExpressionEngine()) must come after the call to
builder.getConfiguration(). If it precedes builder.getConfiguration() then
you get this stack trace:

org.apache.commons.jxpath.JXPathException: Invalid XPath:
'[ <at> systemProperties]'. Syntax error at the beginning of the expression
    at org.apache.commons.jxpath.ri.Parser.parseExpression(Parser.java:60)
    at
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.compileExpression(JXPathContextReferenceImpl.java:218)
    at
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(JXPathContextReferenceImpl.java:529)
    at
org.apache.commons.jxpath.JXPathContext.selectNodes(JXPathContext.java:654)
    at
org.apache.commons.configuration.tree.xpath.XPathExpressionEngine.query(XPathExpressionEngine.java:183)
    at
org.apache.commons.configuration.HierarchicalConfiguration.fetchNodeList(HierarchicalConfiguration.java:958)
    at
org.apache.commons.configuration.AbstractHierarchicalFileConfiguration.fetchNodeList(AbstractHierarchicalFileConfiguration.java:439)
    at
org.apache.commons.configuration.HierarchicalConfiguration.getProperty(HierarchicalConfiguration.java:344)
    at
org.apache.commons.configuration.AbstractHierarchicalFileConfiguration.getProperty(AbstractHierarchicalFileConfiguration.java:392)
    at
org.apache.commons.configuration.AbstractConfiguration.resolveContainerStore(AbstractConfiguration.java:1171)
    at
org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1038)
    at
org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1021)
    at
org.apache.commons.configuration.DefaultConfigurationBuilder.initSystemProperties(DefaultConfigurationBuilder.java:793)
    at
org.apache.commons.configuration.DefaultConfigurationBuilder.getConfiguration(DefaultConfigurationBuilder.java:612)
    at
org.apache.commons.configuration.DefaultConfigurationBuilder.getConfiguration(DefaultConfigurationBuilder.java:587)
    at Test.testSetExpressionEngineBeforeLoad(Test.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

The XPath expression "[ <at> systemProperties]" is hard-coded in the class
DefaultConfigurationBuilder as the static field named KEY_SYSTEM_PROPS. It
appears that this hard-coded value means that DefaultConfigurationBuilder
is not considering that different expression engines can be used. This
problem is easily solved by just waiting to set the expression engine until
after the configuration files have been loaded but I'm not sure what
happens if you have automatic reloading turned on or do other reloading
down the line. Should this be logged in JIRA as a defect or am I just
overlooking some information?

--

-- 
Nick Watts
blog: thewonggei.wordpress.com
twitter:  <at> thewonggei
Johannes Wienke | 9 Sep 11:20 2014
Picon
Picon

Re: [SCXML] onentry executable content parallel to further transitions

Hi,

On 09/08/2014 10:07 PM, Martin Gainty wrote:
> StringTokenizer st = new StringTokenizer(event); 
> 
> int tkns = st.countTokens(); 
> TriggerEvent[] evts = new TriggerEvent[tkns]; 
> for (int i = 0; i < tkns; i++) { 
>    executor.triggerEvents();
> 

But then I have to implement a custom logic to restart that loop once
new events arrive after it finished once. Moreover, this doesn't look
thread-safe.

Cheers,
Johannes

--

-- 
Johannes Wienke, Researcher at CoR-Lab / CITEC, Bielefeld University
Address: Inspiration 1, D-33619 Bielefeld, Germany (Room 1.307)
Phone: +49 521 106-67277

Anjib Mulepati | 8 Sep 21:05 2014
Picon

RE: [net] Handling sequence of sendCommand()

So is that mean TelnetClient run those command in different thread and parallel?

telnet.sendCommand("rand "); telnet.sendCommand("cal "); and telnet.sendCommand("date "); running
at same time?
If yes can you explain me why third command never executed or give output?

From: mgainty <at> hotmail.com
To: anjibcs <at> hotmail.com
Subject: RE: [net] Handling sequence of sendCommand()
Date: Mon, 8 Sep 2014 14:58:51 -0400

> From: anjibcs <at> hotmail.com
> To: user <at> commons.apache.org
> Subject: [net] Handling sequence of sendCommand()
> Date: Mon, 8 Sep 2014 10:52:52 -0500
> 
> Hi All,
> 
> 
> 
> I am using this AutomatedTelnetClient (http://stackoverflow.com/questions/1195809/looking-for-java-telnet-emulator)
> to send sequence of command to telehack.com:23. 
> AutomatedTelnetClient telnet = new AutomatedTelnetClient("telehack.com", "23");
> telnet.sendCommand("rand ");//run OK
> telnet.sendCommand("cal "); //run OK
> telnet.sendCommand("date "); //never run
> 
> 
> first two command run OK and gives me
> output but third one never runs. I change the order of cal and
> date this time rans and date execute but not cal. So it running
> first two commands only.
> 
> 
> 
> So my question is do I have to use some kind of thread in that
> program to do read and write operation from the telnet server?
MG>you want the cycle of input, process, output to complete for each command
MG>before moving onto the next
MG>a blocking thread in combination with a synchronizer would handle this for you
MG>https://today.java.net/pub/a/today/2008/10/23/creating-a-notifying-blocking-thread-pool-executor.html#the-need-for-a-blocking-thread-pool
> 
> 
> 
> Thanks,
> 
> Anjib 
 		 	   		   		 	   		  
Anjib Mulepati | 8 Sep 17:52 2014
Picon

[net] Handling sequence of sendCommand()

Hi All,

    I am using this AutomatedTelnetClient (http://stackoverflow.com/questions/1195809/looking-for-java-telnet-emulator)
      to send sequence of command to telehack.com:23. 
AutomatedTelnetClient telnet = new AutomatedTelnetClient("telehack.com", "23");
telnet.sendCommand("rand ");//run OK
telnet.sendCommand("cal "); //run OK
telnet.sendCommand("date "); //never run

    first two command run OK and gives me
        output but third one never runs. I change the order of cal and
        date this time rans and date execute but not cal. So it running
        first two commands only.

        So my question is do I have to use some kind of thread in that
        program to do read and write operation from the telnet server?

        Thanks,

        Anjib  		 	   		  
Konrad Zuse | 6 Sep 02:05 2014
Picon

[fileupload] - Question about uploading additional files other than the ones in the form?

Hello all,

I am basically uploading a file to my server, but within that file contains path information to images that
also need to be uploaded.  I am looking to read the file mid stream and get the data for the images to upload.  It
seems I am able to do this, but if this is not possible will I be able save the file, read it, and then be able to
get these images?

I am curious about how I will go about grabbing the additional files?  I see that streaming works with
InputStream from JavaIO as well as something from CommonsIO, so I figured I could configure something to
work with the fileupload stream.

I also thought that I could possibly try to create a form through my servlet and pass the data through that,
but I figured this would be the less favorable approach.

If anyone has any advice or thoughts I would appreciate it... Thanks!

 		 	   		  

Gmane