- my webspace

- my webspace

Latest Comment

Allama Iqbal - Selective verse...
Yahoouj
Really good work about this website was done. Keep trying mo...
07/03/10 21:04 More...
By Roderick

Allama Iqbal - Selective verse...
Great Job
You have dont a great job of collecting these... Even I had ...
25/08/09 07:01 More...
By Sikandar

O ye who don't believe !
It's like Lehman Brothers :grin
11/10/08 16:31 More...
By anurag Chaturvedi

I Protest
@Sikku
Thanks Sikku for the feedback. I never intend to blame, a...
29/07/08 17:06 More...
By Aminur Rashid

I Protest
Great !!!
:zzz this is a wonderful story and very honest from the hea...
29/07/08 10:33 More...
By Jennifer Gallagher

Login






Lost Password?
No account yet? Register

Tell a Friend

Home arrow Java
Axis1 date datatype workaround PDF Print E-mail
User Rating: / 1
Written by Aminur Rashid   
Monday, 09 May 2011

If you are handling a legacy system, using Axis (1.4) webservices you must have come across Java2WSDL and WSDL2Java tools. The tools help you to generate a WSDL from a java class as well as generating stubs/skeletons from a WSDL. However if are dealing with java.util.Date fields in your code, you should notice following :
package com.aminur.test.ws.axis1.dateservice;

import java.util.Date;

public abstract class TestService {
	public abstract Date fetchEndDate();

	public void updateEndDate(Date dateToBeSet) {
	}
}

Be first to comment this article
StumbleUponDigg This!Bookmark on Delicious

Add as favourites (41) | Quote this article on your site | Views: 774 | E-mail

Last Updated ( Monday, 09 May 2011 )
Read more...
 
Thread unsafe Format in Java PDF Print E-mail
User Rating: / 0
Written by Aminur Rashid   
Tuesday, 12 April 2011


Recently I was asked by one of our team mate that during load testing, order creation was failing (One of the application I am working on is an Order Management Application) because of wrong inputs. However, the unit tests, with the same input was working fine. Investigation into it, led to (once again) an old jdk "designed" bug 4146524 (or feature). After seeing such issues in a number of applications, I am sure a number of developers are yet not aware of Format objects are not thread-safe. So if you create a Format object (or a MessageFormat, NumberFormat, DecimalFormat, ChoiceFormat, DateFormat or SimpleDateFormat object), it cannot be shared among threads.

Be first to comment this article
StumbleUponDigg This!Bookmark on Delicious

Add as favourites (33) | Quote this article on your site | Views: 1346 | E-mail

Last Updated ( Tuesday, 12 April 2011 )
Read more...
 
Java hangs converting 2-2250738585072012e-308 PDF Print E-mail
User Rating: / 0
Written by Aminur Rashid   
Saturday, 12 February 2011
As explained @exploringbinary.com, try following code
 public class DoubleBug {
      private static void hangRunTime()
      {
          System.out.println("Test:");
          double d = Double.parseDouble("2.2250738585072012e-308");
          System.out.println("Value: " + d);
      }
      public static void hangCompiler()
      {
          //double d = 2.2250738585072012e-308;
          //System.out.println("Value: " + d);
      }
      public static void main(String args[])
      {
         hangRunTime();
      }
}
to get your runtime hanged. Oracle has already released a patch for this and quite interestingly the fix for this was just one keyword addition. Get your jre patched. BTW, this is a PHP bug as well. So in the meantime, you can try bringing down your own website, by sending the String (assuming the server does a double conversion)

Be first to comment this article
StumbleUponDigg This!Bookmark on Delicious

Add as favourites (46) | Quote this article on your site | Views: 427 | E-mail

Last Updated ( Saturday, 12 February 2011 )
 
Quick logger PDF Print E-mail
User Rating: / 1
Written by Aminur Rashid   
Saturday, 14 August 2010
.

Post JDK1.5 you can create a quick logger(if you are not using apache log4j for some reason)as below:

 public Logger {
    public static void log(String msg) {
        System.out.printf("%s : %s",Thread.currentThread().getStackTrace() [2],msg);
    }
}

.

Be first to comment this article
StumbleUponDigg This!Bookmark on Delicious

Add as favourites (57) | Quote this article on your site | Views: 429 | E-mail

Last Updated ( Saturday, 14 August 2010 )
 
When false is true PDF Print E-mail
User Rating: / 1
Written by Aminur Rashid   
Thursday, 12 August 2010
.

While trying to explain reflection to one my young friend, I finally ended up writing this code:

package aminur.test.mutate;

import java.lang.reflect.Field;

public class MutableString {

	public static void main(String[] argv) {
		mutate();
		System.out.println("TRUE".equals("FALSE"));
	}

	public static void mutate() {
		try {
			String t = "TRUE";
			String f = "FALSE";
			Field val = String.class.getDeclaredField("value");
			Field count = String.class.getDeclaredField("count");
			Field off = String.class.getDeclaredField("offset");
			val.setAccessible(true);
			count.setAccessible(true);
			off.setAccessible(true);
			

			count.set(t, f.length());
			val.set(t, f.toCharArray());
			off.set(f, off.getInt(f));
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

This won't work in 1.3/.4 but will work in higher/lower version of JDK

The bug #5044412 fix(?) may disallow setting of value of fields.

Be first to comment this article
StumbleUponDigg This!Bookmark on Delicious

Add as favourites (61) | Quote this article on your site | Views: 534 | E-mail

Last Updated ( Thursday, 12 August 2010 )
 
<< Start < Prev 1 2 Next > End >>

Results 1 - 9 of 13
Aminur Rashid