Friday, August 17, 2012

MoSKito 1.5.0 goes after threads.

As MoSKito 1.5.0 hits the maven repositorty today, so do some new features about threads.
Here's a short overview on 4 new screens added in 1.5.0 for threading issues.

NOTE: We now do have an official anotheria blog: blog.anotheria.net
This post is moved there:
http://blog.anotheria.net/?p=9

Thursday, August 16, 2012

Everything gets better once Oracle buys you

Well, almost.
Recently I had to retrieve my sun developer framework account, I wasn't using for 5 years now.
I was hoping I can vote on this ugly bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7180557 with localhost and java7 on my mac, I was writing about in previous post. Well - no. However, the process itself was funny enough, since they require you to specify both, username and email, and in my case (and I suppose many other cases) its the same, but its not that easy to figure out.

However, sun's and now oracle's mailing system works much better than the update profile dialog, I was forced to fill and submit:















Well, at least we now know what GlassFish version they are running ;-)

Oracle Kills getLocalhost on MacOS X in Java 7

This is going to be another one of those How things that can't happen actually happen post.
I recently updated my Mac to Java 7. Pretty late though. Right after that DistributeMe services start behaving at least strange. Right after the start a service registers itself in a registry with a unique service identifier, which looks like that:

rmi://a_b_c_FooService.qhxgttedwr@192.168.1.113:9252@20120816162707


Where 192.168.1.113 being the ip adress of the machine the service runs on. This adress is used by the client, once the later wants to connect to the service.

After upgrade to Java 7 the service registered itself in the registry with the identifier:

rmi://a_b_c_FooService.qhxgttedwr@unknown:9252@20120816162707

Of course no client were able to resolve the host named unknown. I started investigating where this comes from, and well, it was in one of those sections...


 
private static String getHostName(){
  try{
    InetAddress localhost = InetAddress.getLocalHost();
    String host = localhost.getHostAddress();
    HashMap mappings = configuration.getMappings(); 
    String mappedHost = mappings.get(host);
    return mappedHost == null ? host : mappedHost;
  }catch(UnknownHostException e){
    return "unknown";
  }
}

Ok, this is certainly not the best idea to return "unknown" here (one of those, can't happen anyway bug), but why the heck did InetAddress.getLocalHost() fail?

I wrote a very small program to verify it:

package localhostbug;

import java.net.InetAddress;

public class PrintLocalhost {
  public static void main(String[] args) throws Exception{
    InetAddress localhost = InetAddress.getLocalHost();
    String host = localhost.getHostAddress();
    System.out.println("host: "+host);
  }
}

Running it with JAVA6 and JAVA7 shows the difference, watch yourself:

$JAVA6_HOME/bin/java -cp classes localhostbug.PrintLocalhost
host: 192.168.140.200
and
$JAVA7_HOME/bin/java -cp classes localhostbug.PrintLocalhost
Exception in thread "main" java.net.UnknownHostException: colin.speedport.ip: colin.speedport.ip: nodename nor servname provided, or not known
 at java.net.InetAddress.getLocalHost(InetAddress.java:1438)
 at localhostbug.PrintLocalhost.main(PrintLocalhost.java:7)
Caused by: java.net.UnknownHostException: colin.speedport.ip: nodename nor servname provided, or not known
 at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
 at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:866)
 at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1258)
 at java.net.InetAddress.getLocalHost(InetAddress.java:1434)
 ... 1 more

After some googling I found a bug in oracle bug database and a similar issue in openjdk. Seems Java and Mac is getting less and less a love story.
Sad.