Program: 154067
Project: 154067
Buggy source:
/** 
 * A convenience method to create an instance of <code>ComponentColorModel</code> suitable for use with the given <code>SampleModel</code> and <ColorSpace</code>.  The  <code>SampleModel</code> should have a data type of <code>DataBuffer.TYPE_BYTE</code>, <code>TYPE_USHORT</code>, or <code>TYPE_INT</code> and between 1 and 4 bands.  Depending on the number of bands of the <code>SampleModel</code>, either a gray, gray+alpha, rgb, or rgb+alpha <code>ColorModel</code> is returned.
 */
public static ColorModel createComponentColorModel(SampleModel sm,ColorSpace cp){
  if (cp == null)   return createComponentColorModel(sm);
  int type=sm.getDataType();
  int bands=sm.getNumBands();
  ComponentColorModel cm=null;
  int[] bits=null;
  int transferType=-1;
  boolean hasAlpha=(bands % 2 == 0);
  int transparency=hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE;
  if (type == DataBuffer.TYPE_BYTE) {
    transferType=DataBuffer.TYPE_BYTE;
switch (bands) {
case 1:
      bits=GrayBits8;
    break;
case 2:
  bits=GrayAlphaBits8;
break;
case 3:
bits=RGBBits8;
break;
case 4:
bits=RGBABits8;
break;
}
}
 else if (type == DataBuffer.TYPE_USHORT) {
transferType=DataBuffer.TYPE_USHORT;
switch (bands) {
case 1:
bits=GrayBits16;
break;
case 2:
bits=GrayAlphaBits16;
break;
case 3:
bits=RGBBits16;
break;
case 4:
bits=RGBABits16;
break;
}
}
 else if (type == DataBuffer.TYPE_INT) {
transferType=DataBuffer.TYPE_INT;
switch (bands) {
case 1:
bits=GrayBits32;
break;
case 2:
bits=GrayAlphaBits32;
break;
case 3:
bits=RGBBits32;
break;
case 4:
bits=RGBABits32;
break;
}
}
if (type == DataBuffer.TYPE_FLOAT && bands >= 1 && bands <= 4) {
cm=new FloatDoubleColorModel(cp,hasAlpha,false,transparency,DataBuffer.TYPE_FLOAT);
}
 else {
cm=new ComponentColorModel(cp,bits,hasAlpha,false,transparency,transferType);
}
return cm;
}

Fixed version (ground truth):
/** 
 * A convenience method to create an instance of <code>ComponentColorModel</code> suitable for use with the given <code>SampleModel</code> and <ColorSpace</code>.  The  <code>SampleModel</code> should have a data type of <code>DataBuffer.TYPE_BYTE</code>, <code>TYPE_USHORT</code>, or <code>TYPE_INT</code> and between 1 and 4 bands.  Depending on the number of bands of the <code>SampleModel</code>, either a gray, gray+alpha, rgb, or rgb+alpha <code>ColorModel</code> is returned.
 */
public static ColorModel createComponentColorModel(SampleModel sm,ColorSpace cp){
  if (cp == null)   return createComponentColorModel(sm);
  int type=sm.getDataType();
  int bands=sm.getNumBands();
  ComponentColorModel cm=null;
  int[] bits=null;
  int transferType=-1;
  boolean hasAlpha=(bands % 2 == 0);
  if (cp instanceof SimpleCMYKColorSpace)   hasAlpha=false;
  int transparency=hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE;
  if (type == DataBuffer.TYPE_BYTE) {
    transferType=DataBuffer.TYPE_BYTE;
switch (bands) {
case 1:
      bits=GrayBits8;
    break;
case 2:
  bits=GrayAlphaBits8;
break;
case 3:
bits=RGBBits8;
break;
case 4:
bits=RGBABits8;
break;
}
}
 else if (type == DataBuffer.TYPE_USHORT) {
transferType=DataBuffer.TYPE_USHORT;
switch (bands) {
case 1:
bits=GrayBits16;
break;
case 2:
bits=GrayAlphaBits16;
break;
case 3:
bits=RGBBits16;
break;
case 4:
bits=RGBABits16;
break;
}
}
 else if (type == DataBuffer.TYPE_INT) {
transferType=DataBuffer.TYPE_INT;
switch (bands) {
case 1:
bits=GrayBits32;
break;
case 2:
bits=GrayAlphaBits32;
break;
case 3:
bits=RGBBits32;
break;
case 4:
bits=RGBABits32;
break;
}
}
if (type == DataBuffer.TYPE_FLOAT && bands >= 1 && bands <= 4) {
cm=new FloatDoubleColorModel(cp,hasAlpha,false,transparency,DataBuffer.TYPE_FLOAT);
}
 else {
cm=new ComponentColorModel(cp,bits,hasAlpha,false,transparency,transferType);
}
return cm;
}