nTail eclipse plugin causing serious memory issues

I have this nTail plugin that keeps loading a log file at regular intervals. For some reason, there was some crazy java code that went into infinite loop and increased the size of log file to 700MB. That caused this plugin to consume too much memory, which in turn made eclipse really really slow even after increasing the memory to 2GB. I kept consuming all the memory with in 10 seconds of loading eclipse.

I took me an hour to figure out what when wrong. I renamed the ‘.metadata’ directory in workspace and relaunched eclipse. Every thing worked fine then and i had to reconfigure the plugins. While reconfiguring nTail to load the file, I noticed that log file grew to 700MB. So I deleted those log files. Switched back to the old metadata directory and everything started working fine again.

SHA 256 hash for Oracle in Java

Oracle 11g doesn’t provide a SHA 256 function. I couldn’t find any SHA256 code that doesn’t have any dependencies. I wrote this class so that Oracle can use just this class alone for a SHA256 function.

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;

/**
 * This is a class exclusively created for use in Oracle. This doesn't have any dependencies besides a JVM.
 * com.jReward.security.SHA256EncoderForOracle
 *
 * @author Suneel
 * @version $Revision: 1.1.2.4 $
 * @since Oct 25, 2010 12:05:23 PM
 */
public class SHA256EncoderForOracle
{

 public static String getSHA256( String pwd ) throws Exception
 {
 MessageDigest messageDigest = MessageDigest.getInstance( "SHA-256" );
 byte[] digest;
 try
 {
 digest = messageDigest.digest( mergePasswordAndSalt( pwd.toUpperCase(), "1234", false ).getBytes( "UTF-8" ) );
 }
 catch( UnsupportedEncodingException e )
 {
 throw new IllegalStateException( "UTF-8 not supported!" );
 }

 StringBuilder sb = new StringBuilder();
 for ( byte element : digest )
 {
 sb.append( Integer.toString( ( element & 0xff ) + 0x100, 16 ).substring( 1 ) );
 }

 return sb.toString().toUpperCase();

 }

 protected static String mergePasswordAndSalt( String password, Object salt, boolean strict )
 {
 if ( password == null )
 {
 password = "";
 }

 if ( strict && ( salt != null ) )
 {
 if ( ( salt.toString().lastIndexOf( "{" ) != -1 ) || ( salt.toString().lastIndexOf( "}" ) != -1 ) )
 {
 throw new IllegalArgumentException( "Cannot use { or } in salt.toString()" );
 }
 }

 if ( ( salt == null ) || "".equals( salt ) )
 {
 return password;
 }
 else
 {
 return password + "{" + salt.toString() + "}";
 }
 }

}