nus-yam/ex-repair huggingface dataset:
Program: 135792
Project: 135792
Buggy source:
@Override public void include(ServletRequest servletRequest,ServletResponse servletResponse) throws IOException, ServletException {
  BundleServletRequest bundleServletRequest=new BundleServletRequest(this,(HttpServletRequest)servletRequest);
  String contextPath=_bundleServletContext.getContextPath();
  if (_requestURI != null) {
    bundleServletRequest.setAttribute(JavaConstants.JAVAX_SERVLET_INCLUDE_REQUEST_URI,_bundleServletContext.getContextPath().concat(_requestURI));
  }
  if (contextPath != null) {
    bundleServletRequest.setAttribute(JavaConstants.JAVAX_SERVLET_FORWARD_CONTEXT_PATH,contextPath);
  }
  if (_servletPath != null) {
    bundleServletRequest.setAttribute(JavaConstants.JAVAX_SERVLET_FORWARD_SERVLET_PATH,_servletPath);
  }
  if (_queryString != null) {
    bundleServletRequest.setAttribute(JavaConstants.JAVAX_SERVLET_INCLUDE_QUERY_STRING,_queryString);
  }
  if (_pathInfo != null) {
    bundleServletRequest.setAttribute(JavaConstants.JAVAX_SERVLET_INCLUDE_PATH_INFO,_pathInfo);
  }
  doDispatch(bundleServletRequest,servletResponse);
}

Fixed version (ground truth):
@Override public void include(ServletRequest servletRequest,ServletResponse servletResponse) throws IOException, ServletException {
  BundleServletRequest bundleServletRequest=new BundleServletRequest(this,(HttpServletRequest)servletRequest);
  String contextPath=_bundleServletContext.getContextPath();
  if (_requestURI != null) {
    bundleServletRequest.setAttribute(JavaConstants.JAVAX_SERVLET_INCLUDE_REQUEST_URI,_bundleServletContext.getContextPath().concat(_requestURI));
  }
  if (contextPath != null) {
    bundleServletRequest.setAttribute(JavaConstants.JAVAX_SERVLET_INCLUDE_CONTEXT_PATH,contextPath);
  }
  if (_servletPath != null) {
    bundleServletRequest.setAttribute(JavaConstants.JAVAX_SERVLET_INCLUDE_SERVLET_PATH,_servletPath);
  }
  if (_queryString != null) {
    bundleServletRequest.setAttribute(JavaConstants.JAVAX_SERVLET_INCLUDE_QUERY_STRING,_queryString);
  }
  if (_pathInfo != null) {
    bundleServletRequest.setAttribute(JavaConstants.JAVAX_SERVLET_INCLUDE_PATH_INFO,_pathInfo);
  }
  doDispatch(bundleServletRequest,servletResponse);
}
Program: 135793
Project: 135793
Buggy source:
synchronized public void notifyFileChanged(){
  Log.i("String_Node_Str","String_Node_Str");
  if (timer != null) {
    timer.cancel();
  }
  timer=new Timer();
  timer.schedule(new TimerTask(){
    public void run(){
      timer=null;
      Message message=new Message();
      message.what=MSG_FILE_CHANGED_TIMER;
      handler.sendMessage(message);
    }
  }
,1000);
}

Fixed version (ground truth):
synchronized public void notifyFileChanged(){
  if (timer != null) {
    timer.cancel();
  }
  timer=new Timer();
  timer.schedule(new TimerTask(){
    public void run(){
      timer=null;
      Message message=new Message();
      message.what=MSG_FILE_CHANGED_TIMER;
      handler.sendMessage(message);
    }
  }
,1000);
}
Program: 135794
Project: 135794
Buggy source:
public void getItemSelect(){
  ArrayList<File> files=adapter.getSelectedFiles();
  if (isNormalList()) {
    int mask=MainActivity.MaskNormalListNormal;
    if (files.size() == 1) {
      File file=files.get(0);
      if (file.isDirectory()) {
        mask=MainActivity.MaskNormalListFavor;
      }
 else       if ("String_Node_Str".equals(FileUtil.getFileSuffix(file))) {
        mask=MainActivity.MaskNormalListUnzip;
      }
    }
    Log.i("String_Node_Str",mask + "String_Node_Str");
    Intent intent=new Intent();
    intent.putExtra(FileConst.Extra_Menu_Mask,mask);
    intent.setAction(FileConst.Action_Set_File_Operation_ActionBar);
    getActivity().sendBroadcast(intent);
  }
  Log.i("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void getItemSelect(){
  ArrayList<File> files=adapter.getSelectedFiles();
  if (isNormalList()) {
    int mask=MainActivity.MaskNormalListNormal;
    if (files.size() == 1) {
      File file=files.get(0);
      if (file.isDirectory()) {
        mask=MainActivity.MaskNormalListFavor;
      }
 else       if ("String_Node_Str".equals(FileUtil.getFileSuffix(file))) {
        mask=MainActivity.MaskNormalListUnzip;
      }
    }
    Intent intent=new Intent();
    intent.putExtra(FileConst.Extra_Menu_Mask,mask);
    intent.setAction(FileConst.Action_Set_File_Operation_ActionBar);
    getActivity().sendBroadcast(intent);
  }
}
Program: 135797
Project: 135797
Buggy source:
/** 
 * Normalizes a link extracted from a page given the page's original URI.
 * @param original The URI of the page that is being parsed
 * @param extracted The extracted link from the page
 * @return The normalized URI, or null if there was an error parsing the extracted URI.
 */
public String normalize(String original,String extracted){
  Validate.notBlank(original);
  Validate.notNull(extracted);
  if (StringUtils.startsWith(extracted,JS_PREFIX)) {
    return null;
  }
  URI originalUri=null;
  URI extractedUri=null;
  try {
    originalUri=new URI(original);
    extractedUri=new URI(extracted);
  }
 catch (  URISyntaxException ex) {
    logger.warn("String_Node_Str" + extracted,ex);
    return null;
  }
  UriBuilder retval=UriBuilder.fromUri(extractedUri);
  boolean hasHost=StringUtils.isNotBlank(extractedUri.getHost());
  boolean hasScheme=StringUtils.isNotBlank(extractedUri.getScheme());
  if (!hasHost) {
    retval.host(originalUri.getHost());
    String normalizedPath=normalizePath(originalUri.getPath(),extractedUri.getPath());
    retval.replacePath(normalizedPath);
  }
  if (!hasScheme) {
    retval.scheme(originalUri.getScheme());
  }
  retval.fragment("String_Node_Str");
  return retval.toString();
}

Fixed version (ground truth):
/** 
 * Normalizes a link extracted from a page given the page's original URI.
 * @param original The URI of the page that is being parsed
 * @param extracted The extracted link from the page
 * @return The normalized URI, or null if there was an error parsing the extracted URI.
 */
public String normalize(String original,String extracted){
  Validate.notBlank(original);
  Validate.notNull(extracted);
  if (StringUtils.startsWith(extracted,JS_PREFIX)) {
    return null;
  }
  URI originalUri=null;
  URI extractedUri=null;
  try {
    originalUri=new URI(original);
    extractedUri=new URI(extracted);
  }
 catch (  URISyntaxException ex) {
    logger.warn("String_Node_Str" + extracted,ex);
    return null;
  }
  UriBuilder retval=UriBuilder.fromUri(extractedUri);
  boolean hasHost=StringUtils.isNotBlank(extractedUri.getHost());
  boolean hasScheme=StringUtils.isNotBlank(extractedUri.getScheme());
  if (!hasScheme) {
    retval.scheme(originalUri.getScheme());
  }
  if (!hasHost) {
    retval.host(originalUri.getHost());
    String normalizedPath=normalizePath(originalUri.getPath(),extractedUri.getPath());
    retval.replacePath(normalizedPath);
  }
  retval.fragment("String_Node_Str");
  return retval.toString();
}
Program: 135798
Project: 135798
Buggy source:
private String normalizePath(String originalPath,String extractedPath){
  if (StringUtils.startsWith(extractedPath,"String_Node_Str")) {
    originalPath=findPathDirectory(originalPath);
    while (StringUtils.startsWith(extractedPath,"String_Node_Str") && originalPath.length() > 0) {
      originalPath=removePathChunkAtEnd(originalPath);
      extractedPath=removePathChunkAtStart(extractedPath);
    }
  }
  originalPath=StringUtils.stripEnd(originalPath,"String_Node_Str");
  extractedPath=StringUtils.stripStart(extractedPath,"String_Node_Str");
  return originalPath + "String_Node_Str" + extractedPath;
}

Fixed version (ground truth):
private String normalizePath(String originalPath,String extractedPath){
  originalPath=findPathDirectory(originalPath);
  if (StringUtils.startsWith(extractedPath,"String_Node_Str")) {
    while (StringUtils.startsWith(extractedPath,"String_Node_Str") && originalPath.length() > 0) {
      originalPath=removePathChunkAtEnd(originalPath);
      extractedPath=removePathChunkAtStart(extractedPath);
    }
  }
  originalPath=StringUtils.stripEnd(originalPath,"String_Node_Str");
  extractedPath=StringUtils.stripStart(extractedPath,"String_Node_Str");
  return originalPath + "String_Node_Str" + extractedPath;
}
Program: 135799
Project: 135799
Buggy source:
public boolean containsWord(char[][] matrix,String word){
  for (int i=0; i < matrix.length; i++) {
    for (int j=0; j < matrix[0].length; j++) {
      Set<Integer> used=new HashSet<>();
      if (bfs(matrix,i,j,word,used))       return true;
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean containsWord(char[][] matrix,String word){
  for (int i=0; i < matrix.length; i++) {
    for (int j=0; j < matrix[0].length; j++) {
      Set<Integer> used=new HashSet<>();
      if (dfs(matrix,i,j,word,used))       return true;
    }
  }
  return false;
}
Program: 135800
Project: 135800
Buggy source:
public static void main(String[] args){
  String[] words=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  char[][] matrix=new char[][]{{'t','h','i','s'},{'w','a','t','s'},{'o','a','h','g'},{'f','g','d','t'}};
  Solution solution=new Solution();
  for (  String s : words) {
    System.out.println(s + "String_Node_Str" + solution.containsWord(matrix,s));
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  String[] words=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  char[][] matrix=new char[][]{{'t','h','i','s'},{'w','a','t','s'},{'o','a','h','g'},{'f','g','d','t'}};
  Solution solution=new Solution();
  for (  String s : words) {
    System.out.println(s + "String_Node_Str" + solution.containsWord(matrix,s));
  }
}
Program: 135801
Project: 135801
Buggy source:
/** 
 * Returns BiFunction which does exactly the same as the given AnnoyingBiFunction but without throwing a checked exception that that annoying one might throw. e.g.) <pre> &lt;T, U, R> R doItWithAnnoyance2(T input1, U input2) throws Exception { throw new Exception("Annoying exception!"); } &lt;T, U, R> R doSomething(BiFunction&lt;T, U, R> function) { // ... return function.apply(someInput1, someInput2); } doSomething(shh(this::doItWithAnnoyance2));            // No compile time error doSomething(shh((x, y) -> doItWithAnnoyance2(x, y)));  // No compile time error </pre>
 * @param function The given AnnoyingBiFunction which may or may not throw a checked Exception.
 * @param < T > the input1 type of the function
 * @param < U > the input2 type of the function
 * @param < R > the result type of the function
 * @return BiFunction which can handle any checked Exception thrown by the given AnnoyingBiFunction and wrap it with an unchecked exception that is RuntimeException.
 */
public static <T,U,R>BiFunction<T,U,R> shh(final AnnoyingBiFunction<T,U,R> function){
  Objects.requireNonNull(function,"String_Node_Str");
  return (input1,input2) -> {
    try {
      return function.apply(input1,input2);
    }
 catch (    Exception e) {
      throw new RuntimeException(e);
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Returns BiFunction which does exactly the same as the given AnnoyingBiFunction but without throwing a checked exception that that annoying one might throw. e.g.) <pre> &lt;T, U, R&gt; R doItWithAnnoyance2(T input1, U input2) throws Exception { throw new Exception("Annoying exception!"); } &lt;T, U, R&gt; R doSomething(BiFunction&lt;T, U, R&gt; function) { // ... return function.apply(someInput1, someInput2); } doSomething(shh(this::doItWithAnnoyance2));            // No compile time error doSomething(shh((x, y) -&gt; doItWithAnnoyance2(x, y)));  // No compile time error </pre>
 * @param function The given AnnoyingBiFunction which may or may not throw a checked Exception.
 * @param < T > the input1 type of the function
 * @param < U > the input2 type of the function
 * @param < R > the result type of the function
 * @return BiFunction which can handle any checked Exception thrown by the given AnnoyingBiFunction and wrap it with an unchecked exception that is RuntimeException.
 */
public static <T,U,R>BiFunction<T,U,R> shh(final AnnoyingBiFunction<T,U,R> function){
  Objects.requireNonNull(function,"String_Node_Str");
  return (input1,input2) -> {
    try {
      return function.apply(input1,input2);
    }
 catch (    Exception e) {
      throw new RuntimeException(e);
    }
  }
;
}
Program: 135802
Project: 135802
Buggy source:
/** 
 * <pre> T -&gt; R -&gt; String </pre> <br /> <pre> public class SomeType { private final Long id; public SomeType(final Long id) { this.id = id; } public Long getId() { return id; } } final String result = Arrays.asList(new SomeType(1L), new SomeType(2L), new SomeType(3L)) .stream() .map(toStringOf(SomeType::getId)) .collect(joining(&quot;, &quot;, &quot;(&quot;, &quot;)&quot;)); </pre> <br /> <pre> result: (1, 2, 3) </pre>
 * @param function function to map T to R
 * @param < T >      the given type T
 * @param < R >      the mapped type of the given type T. The R type's toString() method is called to return the result.
 * @return A function to map <code>T -&gt; R -&gt; String</code> (using {@link String#valueOf(Object)})
 */
public static <T,R>Function<T,String> toStringOf(final Function<T,R> function){
  Objects.requireNonNull(function,"String_Node_Str");
  return input -> function.andThen(String::valueOf).apply(input);
}

Fixed version (ground truth):
/** 
 * <pre> T -&gt; R -&gt; String </pre> <br> <pre> public class SomeType { private final Long id; public SomeType(final Long id) { this.id = id; } public Long getId() { return id; } } final String result = Arrays.asList(new SomeType(1L), new SomeType(2L), new SomeType(3L)) .stream() .map(toStringOf(SomeType::getId)) .collect(joining(&quot;, &quot;, &quot;(&quot;, &quot;)&quot;)); </pre> <br> <pre> result: (1, 2, 3) </pre>
 * @param function function to map T to R
 * @param < T >      the given type T
 * @param < R >      the mapped type of the given type T. The R type's toString() method is called to return the result.
 * @return A function to map <code>T -&gt; R -&gt; String</code> (using {@link String#valueOf(Object)})
 */
public static <T,R>Function<T,String> toStringOf(final Function<T,R> function){
  Objects.requireNonNull(function,"String_Node_Str");
  return input -> function.andThen(String::valueOf).apply(input);
}
Program: 135803
Project: 135803
Buggy source:
@Test public final void testLtBigInteger2(){
  final BigInteger number=new BigInteger("String_Node_Str");
  test("String_Node_Str","String_Node_Str").when(() -> Numbers.BigIntegers.lt(new BigInteger("String_Node_Str"))).then(actual -> assertThat(actual.test(number)).isTrue());
}

Fixed version (ground truth):
@Test public final void testLtBigInteger2(){
  final BigInteger number=new BigInteger("String_Node_Str");
  test("String_Node_Str","String_Node_Str").when(() -> Numbers.BigIntegers.lt(new BigInteger("String_Node_Str"))).then(actual -> assertThat(actual.test(number)).isFalse());
}
Program: 135804
Project: 135804
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void stop(){
  workerGroup.shutdownGracefully().awaitUninterruptibly();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void stop(){
  workerGroup.shutdownGracefully().syncUninterruptibly();
}
Program: 135805
Project: 135805
Buggy source:
@Test public void testChunkedEncode() throws Exception {
  final EmbeddedChannel channel=new EmbeddedChannel(new GelfMessageChunkEncoder());
  final String largeMessage=largeMessage(1500);
  channel.writeOutbound(Unpooled.wrappedBuffer(largeMessage.getBytes()));
  final ByteBuf chunk1=(ByteBuf)channel.readOutbound();
  final ByteBuf chunk2=(ByteBuf)channel.readOutbound();
  assertNull(channel.readOutbound());
  assertEquals((byte)0x1e,chunk1.readByte());
  assertEquals((byte)0x0f,chunk1.readByte());
  assertEquals((byte)0x1e,chunk2.readByte());
  assertEquals((byte)0x0f,chunk2.readByte());
  assertEquals(8,chunk1.readBytes(8).readableBytes());
  assertEquals(8,chunk2.readBytes(8).readableBytes());
  assertEquals((byte)0,chunk1.readByte());
  assertEquals((byte)1,chunk2.readByte());
  assertEquals((byte)2,chunk1.readByte());
  assertEquals((byte)2,chunk2.readByte());
  assertEquals(1420,chunk1.readableBytes());
  assertEquals(largeMessage.length() - 1420,chunk2.readableBytes());
}

Fixed version (ground truth):
@Test public void testChunkedEncode() throws Exception {
  final EmbeddedChannel channel=new EmbeddedChannel(new GelfMessageChunkEncoder());
  final String largeMessage=largeMessage(1500);
  channel.writeOutbound(Unpooled.wrappedBuffer(largeMessage.getBytes(StandardCharsets.US_ASCII)));
  final ByteBuf chunk1=(ByteBuf)channel.readOutbound();
  final ByteBuf chunk2=(ByteBuf)channel.readOutbound();
  assertNull(channel.readOutbound());
  assertEquals((byte)0x1e,chunk1.readByte());
  assertEquals((byte)0x0f,chunk1.readByte());
  assertEquals((byte)0x1e,chunk2.readByte());
  assertEquals((byte)0x0f,chunk2.readByte());
  assertEquals(8,chunk1.readBytes(8).readableBytes());
  assertEquals(8,chunk2.readBytes(8).readableBytes());
  assertEquals((byte)0,chunk1.readByte());
  assertEquals((byte)1,chunk2.readByte());
  assertEquals((byte)2,chunk1.readByte());
  assertEquals((byte)2,chunk2.readByte());
  assertEquals(1420,chunk1.readableBytes());
  assertEquals(largeMessage.length() - 1420,chunk2.readableBytes());
}
Program: 135806
Project: 135806
Buggy source:
@Test public void testEncode() throws Exception {
  InetSocketAddress remoteAddress=new InetSocketAddress("String_Node_Str",12201);
  EmbeddedChannel channel=new EmbeddedChannel(new GelfMessageUdpEncoder(remoteAddress));
  assertTrue(channel.writeOutbound(Unpooled.wrappedBuffer("String_Node_Str".getBytes())));
  assertTrue(channel.finish());
  DatagramPacket datagramPacket=(DatagramPacket)channel.readOutbound();
  byte[] bytes=new byte[datagramPacket.content().readableBytes()];
  datagramPacket.content().getBytes(0,bytes);
  assertEquals(remoteAddress,datagramPacket.recipient());
  assertEquals("String_Node_Str",new String(bytes));
}

Fixed version (ground truth):
@Test public void testEncode() throws Exception {
  InetSocketAddress remoteAddress=new InetSocketAddress("String_Node_Str",12201);
  EmbeddedChannel channel=new EmbeddedChannel(new GelfMessageUdpEncoder(remoteAddress));
  assertTrue(channel.writeOutbound(Unpooled.wrappedBuffer("String_Node_Str".getBytes(StandardCharsets.US_ASCII))));
  assertTrue(channel.finish());
  DatagramPacket datagramPacket=(DatagramPacket)channel.readOutbound();
  byte[] bytes=new byte[datagramPacket.content().readableBytes()];
  datagramPacket.content().getBytes(0,bytes);
  assertEquals(remoteAddress,datagramPacket.recipient());
  assertEquals("String_Node_Str",new String(bytes,StandardCharsets.US_ASCII));
}
Program: 135807
Project: 135807
Buggy source:
public boolean getChild(int groupPosition,int childPosition){
  if (hasStableIds()) {
    return childIds.containsKey(getChildId(groupPosition,childPosition));
  }
 else {
    long packedPosition=ExpandableListView.getPackedPositionForChild(groupPosition,childPosition);
    return childPositions.contains(packedPosition);
  }
}

Fixed version (ground truth):
/** 
 * @return The checked state of a child with the given positions.
 */
public boolean getChild(int groupPosition,int childPosition){
  if (hasStableIds()) {
    return childIds.containsKey(getChildId(groupPosition,childPosition));
  }
 else {
    long packedPosition=ExpandableListView.getPackedPositionForChild(groupPosition,childPosition);
    return childPositions.contains(packedPosition);
  }
}
Program: 135808
Project: 135808
Buggy source:
public boolean getGroup(int groupPosition){
  if (hasStableIds())   return groupIds.containsKey(getGroupId(groupPosition));
 else   return groupPositions.contains(groupPosition);
}

Fixed version (ground truth):
/** 
 * @return The checked state of a group with the given group position
 */
public boolean getGroup(int groupPosition){
  if (hasStableIds())   return groupIds.containsKey(getGroupId(groupPosition));
 else   return groupPositions.contains(groupPosition);
}
Program: 135809
Project: 135809
Buggy source:
public boolean putChild(int groupPosition,int childPosition,long childId,boolean isChecked){
  long packedPosition=ExpandableListView.getPackedPositionForChild(groupPosition,childPosition);
  if (hasStableIds()) {
    Long result=(isChecked) ? childIds.put(childId,packedPosition) : childIds.remove(childId);
    return result != null;
  }
 else {
    return (isChecked) ? childPositions.add(packedPosition) : childPositions.remove(packedPosition);
  }
}

Fixed version (ground truth):
/** 
 * Records the checked state of the given child positions.
 * @return The previous checked state of the child position.
 */
public boolean putChild(int groupPosition,int childPosition,long childId,boolean isChecked){
  long packedPosition=ExpandableListView.getPackedPositionForChild(groupPosition,childPosition);
  if (hasStableIds()) {
    Long result=(isChecked) ? childIds.put(childId,packedPosition) : childIds.remove(childId);
    return result != null;
  }
 else {
    return (isChecked) ? !childPositions.add(packedPosition) : childPositions.remove(packedPosition);
  }
}
Program: 135810
Project: 135810
Buggy source:
public boolean putGroup(int groupPosition,long groupId,boolean isChecked){
  if (hasStableIds()) {
    Integer result=(isChecked) ? groupIds.put(groupId,groupPosition) : groupIds.remove(groupId);
    return result != null;
  }
 else {
    return (isChecked) ? groupPositions.add(groupPosition) : groupPositions.remove(groupPosition);
  }
}

Fixed version (ground truth):
/** 
 * Records the checked state of the given group position.
 * @return The previous checked state of the group position.
 */
public boolean putGroup(int groupPosition,long groupId,boolean isChecked){
  if (hasStableIds()) {
    Integer result=(isChecked) ? groupIds.put(groupId,groupPosition) : groupIds.remove(groupId);
    return result != null;
  }
 else {
    return (isChecked) ? !groupPositions.add(groupPosition) : groupPositions.remove(groupPosition);
  }
}
Program: 135812
Project: 135812
Buggy source:
@Override public void onFailure(Throwable throwable){
  _logger.error("String_Node_Str",writeTransaction.getIdentifier(),throwable.getCause());
}

Fixed version (ground truth):
@Override public void onFailure(Throwable throwable){
  LOG.error("String_Node_Str",writeTransaction.getIdentifier(),throwable.getCause());
}
Program: 135813
Project: 135813
Buggy source:
@Override public void onSuccess(Object o){
  _logger.debug("String_Node_Str",writeTransaction.getIdentifier());
}

Fixed version (ground truth):
@Override public void onSuccess(Object o){
  LOG.debug("String_Node_Str",writeTransaction.getIdentifier());
}
Program: 135815
Project: 135815
Buggy source:
@Override public void onFailure(Throwable throwable){
  _logger.error("String_Node_Str",writeTransaction.getIdentifier(),throwable.getCause());
}

Fixed version (ground truth):
@Override public void onFailure(Throwable throwable){
  LOG.error("String_Node_Str",writeTransaction.getIdentifier(),throwable.getCause());
}
Program: 135816
Project: 135816
Buggy source:
@Override public void onSuccess(Object o){
  _logger.debug("String_Node_Str",writeTransaction.getIdentifier());
}

Fixed version (ground truth):
@Override public void onSuccess(Object o){
  LOG.debug("String_Node_Str",writeTransaction.getIdentifier());
}
Program: 135818
Project: 135818
Buggy source:
/** 
 * Puts the given value (Host) only in this local HashMap. Ideally used for host data listener events.
 * @param ii the value's (Host's) InstanceIdentifier<Node> f
 * @param value the Host to store locally.
 * @return the previous value associated with <tt>key</tt>, or<tt>null</tt> if there was no mapping for <tt>key</tt>
 */
public synchronized V putLocally(InstanceIdentifier<Node> ii,V value){
  Host h=((Host)value);
  log.trace("String_Node_Str",h.getId());
  this.instanceIDs.put(ii,(K)h.getId());
  return this.hostHashMap.put((K)h.getId(),value);
}

Fixed version (ground truth):
/** 
 * Puts the given value (Host) only in this local HashMap. Ideally used for host data listener events.
 * @param ii the value's (Host's) InstanceIdentifier&lt;Node&gt;
 * @param value the Host to store locally.
 * @return the previous value associated with <tt>key</tt>, or<tt>null</tt> if there was no mapping for <tt>key</tt>
 */
public synchronized V putLocally(InstanceIdentifier<Node> ii,V value){
  Host h=((Host)value);
  log.trace("String_Node_Str",h.getId());
  this.instanceIDs.put(ii,(K)h.getId());
  return this.hostHashMap.put((K)h.getId(),value);
}
Program: 135819
Project: 135819
Buggy source:
/** 
 * Writes mac-to-mac flow on all ports that are in the path between given source and destination ports. It uses path provided by NetworkGraphService  {@link org.opendaylight.controller.sample.l2switch.md.topology.NetworkGraphService} to find a links{@link org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link}between given ports. And then writes appropriate flow on each port that is covered in that path.
 * @param sourceMac
 * @param sourceNodeConnectorRef
 * @param destMac
 * @param destNodeConnectorRef
 */
public void addBidirectionalMacToMacFlows(MacAddress sourceMac,NodeConnectorRef sourceNodeConnectorRef,MacAddress destMac,NodeConnectorRef destNodeConnectorRef);

Fixed version (ground truth):
/** 
 * Writes mac-to-mac flow on all ports that are in the path between given source and destination ports. It uses path provided by org.opendaylight.l2switch.loopremover.topology.NetworkGraphService to find a links  {@link org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link}between given ports. And then writes appropriate flow on each port that is covered in that path.
 * @param sourceMac
 * @param sourceNodeConnectorRef
 * @param destMac
 * @param destNodeConnectorRef
 */
public void addBidirectionalMacToMacFlows(MacAddress sourceMac,NodeConnectorRef sourceNodeConnectorRef,MacAddress destMac,NodeConnectorRef destNodeConnectorRef);
Program: 135820
Project: 135820
Buggy source:
/** 
 * Writes mac-to-mac flow on all ports that are in the path between given source and destination ports. It uses path provided by NetworkGraphService  {@link org.opendaylight.controller.sample.l2switch.md.topology.NetworkGraphService} to find a links{@link org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link}between given ports. And then writes appropriate flow on each port that is covered in that path.
 * @param sourceMac
 * @param sourceNodeConnectorRef
 * @param destMac
 * @param destNodeConnectorRef
 */
@Override public void addBidirectionalMacToMacFlows(MacAddress sourceMac,NodeConnectorRef sourceNodeConnectorRef,MacAddress destMac,NodeConnectorRef destNodeConnectorRef){
  Preconditions.checkNotNull(sourceMac,"String_Node_Str");
  Preconditions.checkNotNull(sourceNodeConnectorRef,"String_Node_Str");
  Preconditions.checkNotNull(destMac,"String_Node_Str");
  Preconditions.checkNotNull(destNodeConnectorRef,"String_Node_Str");
  if (sourceNodeConnectorRef.equals(destNodeConnectorRef)) {
    _logger.info("String_Node_Str");
    return;
  }
  addMacToMacFlow(destMac,sourceMac,sourceNodeConnectorRef);
  addMacToMacFlow(sourceMac,destMac,destNodeConnectorRef);
}

Fixed version (ground truth):
/** 
 * Writes mac-to-mac flow on all ports that are in the path between given source and destination ports. It uses path provided by org.opendaylight.l2switch.loopremover.topology.NetworkGraphService to find a links  {@link org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link}between given ports. And then writes appropriate flow on each port that is covered in that path.
 * @param sourceMac
 * @param sourceNodeConnectorRef
 * @param destMac
 * @param destNodeConnectorRef
 */
@Override public void addBidirectionalMacToMacFlows(MacAddress sourceMac,NodeConnectorRef sourceNodeConnectorRef,MacAddress destMac,NodeConnectorRef destNodeConnectorRef){
  Preconditions.checkNotNull(sourceMac,"String_Node_Str");
  Preconditions.checkNotNull(sourceNodeConnectorRef,"String_Node_Str");
  Preconditions.checkNotNull(destMac,"String_Node_Str");
  Preconditions.checkNotNull(destNodeConnectorRef,"String_Node_Str");
  if (sourceNodeConnectorRef.equals(destNodeConnectorRef)) {
    _logger.info("String_Node_Str");
    return;
  }
  addMacToMacFlow(destMac,sourceMac,sourceNodeConnectorRef);
  addMacToMacFlow(sourceMac,destMac,destNodeConnectorRef);
}
Program: 135822
Project: 135822
Buggy source:
/** 
 * Bits are expected to be stored in the input byte array from LSB
 * @param byte[]      - data to set the input byte
 * @param byte[]      - input bytes to be inserted
 * @param startOffset - offset of data[] to start inserting byte from
 * @param numBits     - number of bits of input to be inserted into data[]
 * @return void
 * @throws BufferException when the startOffset and numBits parameters are not congruentwith data and input buffers' size
 */
public static void setBytes(byte[] data,byte[] input,int startOffset,int numBits) throws BufferException {
  checkExceptions(data,startOffset,numBits);
  insertBits(data,input,startOffset,numBits);
}

Fixed version (ground truth):
/** 
 * Bits are expected to be stored in the input byte array from LSB
 * @param data        data to set the input byte
 * @param input       input bytes to be inserted
 * @param startOffset offset of data[] to start inserting byte from
 * @param numBits     number of bits of input to be inserted into data[]
 * @throws BufferException when the startOffset and numBits parameters are not congruentwith data and input buffers' size
 */
public static void setBytes(byte[] data,byte[] input,int startOffset,int numBits) throws BufferException {
  checkExceptions(data,startOffset,numBits);
  insertBits(data,input,startOffset,numBits);
}
Program: 135824
Project: 135824
Buggy source:
/** 
 * Bits are expected to be stored in the input byte array from LSB
 * @param byte[]      - data to set the input byte
 * @param byte        - input byte to be inserted
 * @param startOffset - offset of data[] to start inserting byte from
 * @param numBits     - number of bits of input to be inserted into data[]
 * @throws BufferException when the input, startOffset and numBits are not congruentwith the data buffer size
 */
public static void setByte(byte[] data,byte input,int startOffset,int numBits) throws BufferException {
  byte[] inputByteArray=new byte[1];
  Arrays.fill(inputByteArray,0,1,input);
  setBytes(data,inputByteArray,startOffset,numBits);
}

Fixed version (ground truth):
/** 
 * Bits are expected to be stored in the input byte array from LSB
 * @param data        data to set the input byte
 * @param input       byte to be inserted
 * @param startOffset offset in data to start inserting byte from
 * @param numBits     number of bits of input to be inserted into data[]
 * @throws BufferException when the input, startOffset and numBits are not congruentwith the data buffer size
 */
public static void setByte(byte[] data,byte input,int startOffset,int numBits) throws BufferException {
  byte[] inputByteArray=new byte[1];
  Arrays.fill(inputByteArray,0,1,input);
  setBytes(data,inputByteArray,startOffset,numBits);
}
Program: 135825
Project: 135825
Buggy source:
/** 
 * Returns the first byte from the byte array
 * @param byte[] data
 * @return byte value
 */
public static byte getByte(byte[] data){
  if ((data.length * NetUtils.NumBitsInAByte) > Byte.SIZE) {
    try {
      throw new BufferException("String_Node_Str");
    }
 catch (    BufferException e) {
      logger.error("String_Node_Str",e);
    }
  }
  return (data[0]);
}

Fixed version (ground truth):
/** 
 * Returns the first byte from the byte array
 * @param data
 * @return byte value
 */
public static byte getByte(byte[] data){
  if ((data.length * NetUtils.NumBitsInAByte) > Byte.SIZE) {
    try {
      throw new BufferException("String_Node_Str");
    }
 catch (    BufferException e) {
      logger.error("String_Node_Str",e);
    }
  }
  return (data[0]);
}
Program: 135826
Project: 135826
Buggy source:
/** 
 * Returns the short value for the last numBits of the byte array passed. Size of numBits is restricted to Short.SIZE
 * @param byte[] data
 * @param int    - numBits
 * @return short - the short value of byte array
 */
public static short getShort(byte[] data,int numBits){
  if (numBits > Short.SIZE) {
    try {
      throw new BufferException("String_Node_Str");
    }
 catch (    BufferException e) {
      logger.error("String_Node_Str",e);
    }
  }
  int startOffset=data.length * NetUtils.NumBitsInAByte - numBits;
  byte[] bits=null;
  try {
    bits=BitBufferHelper.getBits(data,startOffset,numBits);
  }
 catch (  BufferException e) {
    logger.error("String_Node_Str",e);
  }
  return (short)toNumber(bits,numBits);
}

Fixed version (ground truth):
/** 
 * Returns the short value for the last numBits of the byte array passed. Size of numBits is restricted to Short.SIZE
 * @param data
 * @param numBits
 * @return the short value of byte array
 */
public static short getShort(byte[] data,int numBits){
  if (numBits > Short.SIZE) {
    try {
      throw new BufferException("String_Node_Str");
    }
 catch (    BufferException e) {
      logger.error("String_Node_Str",e);
    }
  }
  int startOffset=data.length * NetUtils.NumBitsInAByte - numBits;
  byte[] bits=null;
  try {
    bits=BitBufferHelper.getBits(data,startOffset,numBits);
  }
 catch (  BufferException e) {
    logger.error("String_Node_Str",e);
  }
  return (short)toNumber(bits,numBits);
}
Program: 135827
Project: 135827
Buggy source:
/** 
 * Checks for overflow and underflow exceptions
 * @param data
 * @param startOffset
 * @param numBits
 * @throws PacketException when the startOffset and numBits parametersare not congruent with the data buffer's size
 */
public static void checkExceptions(byte[] data,int startOffset,int numBits) throws BufferException {
  int endOffsetByte;
  int startByteOffset;
  endOffsetByte=startOffset / NetUtils.NumBitsInAByte + numBits / NetUtils.NumBitsInAByte + ((numBits % NetUtils.NumBitsInAByte != 0) ? 1 : ((startOffset % NetUtils.NumBitsInAByte != 0) ? 1 : 0));
  startByteOffset=startOffset / NetUtils.NumBitsInAByte;
  if (data == null) {
    throw new BufferException("String_Node_Str");
  }
  if ((startOffset < 0) || (startByteOffset >= data.length) || (endOffsetByte > data.length)|| (numBits < 0)|| (numBits > NetUtils.NumBitsInAByte * data.length)) {
    throw new BufferException("String_Node_Str" + data.length + "String_Node_Str"+ startOffset+ "String_Node_Str"+ numBits);
  }
}

Fixed version (ground truth):
/** 
 * Checks for overflow and underflow exceptions
 * @param data
 * @param startOffset
 * @param numBits
 * @throws BufferException when the startOffset and numBits parametersare not congruent with the data buffer's size
 */
public static void checkExceptions(byte[] data,int startOffset,int numBits) throws BufferException {
  int endOffsetByte;
  int startByteOffset;
  endOffsetByte=startOffset / NetUtils.NumBitsInAByte + numBits / NetUtils.NumBitsInAByte + ((numBits % NetUtils.NumBitsInAByte != 0) ? 1 : ((startOffset % NetUtils.NumBitsInAByte != 0) ? 1 : 0));
  startByteOffset=startOffset / NetUtils.NumBitsInAByte;
  if (data == null) {
    throw new BufferException("String_Node_Str");
  }
  if ((startOffset < 0) || (startByteOffset >= data.length) || (endOffsetByte > data.length)|| (numBits < 0)|| (numBits > NetUtils.NumBitsInAByte * data.length)) {
    throw new BufferException("String_Node_Str" + data.length + "String_Node_Str"+ startOffset+ "String_Node_Str"+ numBits);
  }
}
Program: 135828
Project: 135828
Buggy source:
/** 
 * Returns the long value for the last numBits of the byte array passed. Size of numBits is restricted to Long.SIZE
 * @param byte[] data
 * @param int    - numBits
 * @return long - the integer value of byte array
 */
public static long getLong(byte[] data,int numBits){
  if (numBits > Long.SIZE) {
    try {
      throw new BufferException("String_Node_Str");
    }
 catch (    BufferException e) {
      logger.error("String_Node_Str",e);
    }
  }
  if (numBits > data.length * NetUtils.NumBitsInAByte) {
    try {
      throw new BufferException("String_Node_Str");
    }
 catch (    BufferException e) {
      logger.error("String_Node_Str",e);
    }
  }
  int startOffset=data.length * NetUtils.NumBitsInAByte - numBits;
  byte[] bits=null;
  try {
    bits=BitBufferHelper.getBits(data,startOffset,numBits);
  }
 catch (  BufferException e) {
    logger.error("String_Node_Str",e);
  }
  return (long)toNumber(bits,numBits);
}

Fixed version (ground truth):
/** 
 * Returns the long value for the last numBits of the byte array passed. Size of numBits is restricted to Long.SIZE
 * @param data
 * @param numBits
 * @return the integer value of byte array
 */
public static long getLong(byte[] data,int numBits){
  if (numBits > Long.SIZE) {
    try {
      throw new BufferException("String_Node_Str");
    }
 catch (    BufferException e) {
      logger.error("String_Node_Str",e);
    }
  }
  if (numBits > data.length * NetUtils.NumBitsInAByte) {
    try {
      throw new BufferException("String_Node_Str");
    }
 catch (    BufferException e) {
      logger.error("String_Node_Str",e);
    }
  }
  int startOffset=data.length * NetUtils.NumBitsInAByte - numBits;
  byte[] bits=null;
  try {
    bits=BitBufferHelper.getBits(data,startOffset,numBits);
  }
 catch (  BufferException e) {
    logger.error("String_Node_Str",e);
  }
  return (long)toNumber(bits,numBits);
}
Program: 135829
Project: 135829
Buggy source:
/** 
 * Returns the int value for the last numBits of the byte array passed. Size of numBits is restricted to Integer.SIZE
 * @param byte[] data
 * @param int    - numBits
 * @return int - the integer value of byte array
 */
public static int getInt(byte[] data,int numBits){
  if (numBits > Integer.SIZE) {
    try {
      throw new BufferException("String_Node_Str");
    }
 catch (    BufferException e) {
      logger.error("String_Node_Str",e);
    }
  }
  int startOffset=data.length * NetUtils.NumBitsInAByte - numBits;
  byte[] bits=null;
  try {
    bits=BitBufferHelper.getBits(data,startOffset,numBits);
  }
 catch (  BufferException e) {
    logger.error("String_Node_Str",e);
  }
  return (int)toNumber(bits,numBits);
}

Fixed version (ground truth):
/** 
 * Returns the int value for the last numBits of the byte array passed. Size of numBits is restricted to Integer.SIZE
 * @param data
 * @param numBits
 * @return the integer value of byte array
 */
public static int getInt(byte[] data,int numBits){
  if (numBits > Integer.SIZE) {
    try {
      throw new BufferException("String_Node_Str");
    }
 catch (    BufferException e) {
      logger.error("String_Node_Str",e);
    }
  }
  int startOffset=data.length * NetUtils.NumBitsInAByte - numBits;
  byte[] bits=null;
  try {
    bits=BitBufferHelper.getBits(data,startOffset,numBits);
  }
 catch (  BufferException e) {
    logger.error("String_Node_Str",e);
  }
  return (int)toNumber(bits,numBits);
}
Program: 135831
Project: 135831
Buggy source:
/** 
 * Accepts a number as input and returns its value in byte form in MSB aligned form example: input = 5000 [1001110001000] bytes = -114, 64 [10011100] [01000000]
 * @param Number input
 * @param int    numBits - the number of bits to be returned
 * @return byte[]
 */
public static byte[] toByteArray(Number input,int numBits){
  Class<? extends Number> dataType=input.getClass();
  short size=0;
  long longValue=input.longValue();
  if (dataType == Short.class) {
    size=Short.SIZE;
  }
 else   if (dataType == Integer.class) {
    size=Integer.SIZE;
  }
 else   if (dataType == Long.class) {
    size=Long.SIZE;
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int length=size / NetUtils.NumBitsInAByte;
  byte bytes[]=new byte[length];
  byte[] inputbytes=new byte[length];
  byte shiftedBytes[];
  for (int i=0; i < length; i++) {
    bytes[i]=(byte)((longValue >> (NetUtils.NumBitsInAByte * (length - i - 1))) & ByteMask);
  }
  if ((bytes[0] == 0 && dataType == Long.class) || (bytes[0] == 0 && dataType == Integer.class)) {
    int index=0;
    for (index=0; index < length; ++index) {
      if (bytes[index] != 0) {
        bytes[0]=bytes[index];
        break;
      }
    }
    System.arraycopy(bytes,index,inputbytes,0,length - index);
    Arrays.fill(bytes,length - index + 1,length - 1,(byte)0);
  }
 else {
    System.arraycopy(bytes,0,inputbytes,0,length);
  }
  shiftedBytes=shiftBitsToMSB(inputbytes,numBits);
  return shiftedBytes;
}

Fixed version (ground truth):
/** 
 * Accepts a number as input and returns its value in byte form in MSB aligned form example: input = 5000 [1001110001000] bytes = -114, 64 [10011100] [01000000]
 * @param input
 * @param numBits the number of bits to be returned
 * @return byte[]
 */
public static byte[] toByteArray(Number input,int numBits){
  Class<? extends Number> dataType=input.getClass();
  short size=0;
  long longValue=input.longValue();
  if (dataType == Short.class) {
    size=Short.SIZE;
  }
 else   if (dataType == Integer.class) {
    size=Integer.SIZE;
  }
 else   if (dataType == Long.class) {
    size=Long.SIZE;
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int length=size / NetUtils.NumBitsInAByte;
  byte bytes[]=new byte[length];
  byte[] inputbytes=new byte[length];
  byte shiftedBytes[];
  for (int i=0; i < length; i++) {
    bytes[i]=(byte)((longValue >> (NetUtils.NumBitsInAByte * (length - i - 1))) & ByteMask);
  }
  if ((bytes[0] == 0 && dataType == Long.class) || (bytes[0] == 0 && dataType == Integer.class)) {
    int index=0;
    for (index=0; index < length; ++index) {
      if (bytes[index] != 0) {
        bytes[0]=bytes[index];
        break;
      }
    }
    System.arraycopy(bytes,index,inputbytes,0,length - index);
    Arrays.fill(bytes,length - index + 1,length - 1,(byte)0);
  }
 else {
    System.arraycopy(bytes,0,inputbytes,0,length);
  }
  shiftedBytes=shiftBitsToMSB(inputbytes,numBits);
  return shiftedBytes;
}
Program: 135833
Project: 135833
Buggy source:
/** 
 * It aligns the first numBits bits to the right end of the byte array preceding them with numBits % 8 zero bits. <p/> Example: For inputbytes = [01110111][00010000] and numBits = 12 it returns: shiftedBytes = [00000111][01110001]
 * @param byte[] inputBytes
 * @param int    numBits - number of bits to be right aligned
 * @return byte[]
 */
public static byte[] shiftBitsToLSB(byte[] inputBytes,int numBits){
  int numBytes=inputBytes.length;
  int numBitstoShift=numBits % NetUtils.NumBitsInAByte;
  byte[] shiftedBytes=new byte[numBytes];
  int inputLsb=0, inputMsb=0;
  if (numBitstoShift == 0) {
    return inputBytes;
  }
  for (int i=1; i < numBytes; i++) {
    inputLsb=inputBytes[i - 1] & getLSBMask(NetUtils.NumBitsInAByte - numBitstoShift);
    inputLsb=(inputLsb < 0) ? (inputLsb + 256) : inputLsb;
    inputMsb=inputBytes[i] & getMSBMask(numBitstoShift);
    inputMsb=(inputBytes[i] < 0) ? (inputBytes[i] + 256) : inputBytes[i];
    shiftedBytes[i]=(byte)((inputLsb << numBitstoShift) | (inputMsb >> (NetUtils.NumBitsInAByte - numBitstoShift)));
  }
  inputMsb=inputBytes[0] & (getMSBMask(numBitstoShift));
  inputMsb=(inputMsb < 0) ? (inputMsb + 256) : inputMsb;
  shiftedBytes[0]=(byte)(inputMsb >> (NetUtils.NumBitsInAByte - numBitstoShift));
  return shiftedBytes;
}

Fixed version (ground truth):
/** 
 * It aligns the first numBits bits to the right end of the byte array preceding them with numBits % 8 zero bits. <p> Example: For inputbytes = [01110111][00010000] and numBits = 12 it returns: shiftedBytes = [00000111][01110001]
 * @param inputBytes
 * @param numBits number of bits to be right aligned
 * @return byte[]
 */
public static byte[] shiftBitsToLSB(byte[] inputBytes,int numBits){
  int numBytes=inputBytes.length;
  int numBitstoShift=numBits % NetUtils.NumBitsInAByte;
  byte[] shiftedBytes=new byte[numBytes];
  int inputLsb=0, inputMsb=0;
  if (numBitstoShift == 0) {
    return inputBytes;
  }
  for (int i=1; i < numBytes; i++) {
    inputLsb=inputBytes[i - 1] & getLSBMask(NetUtils.NumBitsInAByte - numBitstoShift);
    inputLsb=(inputLsb < 0) ? (inputLsb + 256) : inputLsb;
    inputMsb=inputBytes[i] & getMSBMask(numBitstoShift);
    inputMsb=(inputBytes[i] < 0) ? (inputBytes[i] + 256) : inputBytes[i];
    shiftedBytes[i]=(byte)((inputLsb << numBitstoShift) | (inputMsb >> (NetUtils.NumBitsInAByte - numBitstoShift)));
  }
  inputMsb=inputBytes[0] & (getMSBMask(numBitstoShift));
  inputMsb=(inputMsb < 0) ? (inputMsb + 256) : inputMsb;
  shiftedBytes[0]=(byte)(inputMsb >> (NetUtils.NumBitsInAByte - numBitstoShift));
  return shiftedBytes;
}
Program: 135834
Project: 135834
Buggy source:
/** 
 * Returns the numerical value of the last numBits (LSB bits) of the byte array passed
 * @param byte[] - array
 * @param int    - numBits
 * @return long - numerical value of byte array passed
 */
static public long toNumber(byte[] array,int numBits){
  int length=numBits / NetUtils.NumBitsInAByte;
  int bitsRest=numBits % NetUtils.NumBitsInAByte;
  int startOffset=array.length - length;
  long ret=0;
  int value=0;
  value=array[startOffset - 1] & getLSBMask(bitsRest);
  value=(array[startOffset - 1] < 0) ? (array[startOffset - 1] + 256) : array[startOffset - 1];
  ret=ret | (value << ((array.length - startOffset) * NetUtils.NumBitsInAByte));
  for (int i=startOffset; i < array.length; i++) {
    value=array[i];
    if (value < 0)     value+=256;
    ret=ret | (long)((long)value << ((array.length - i - 1) * NetUtils.NumBitsInAByte));
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Returns the numerical value of the last numBits (LSB bits) of the byte array passed
 * @param array
 * @param numBits
 * @return numerical value of byte array passed
 */
static public long toNumber(byte[] array,int numBits){
  int length=numBits / NetUtils.NumBitsInAByte;
  int bitsRest=numBits % NetUtils.NumBitsInAByte;
  int startOffset=array.length - length;
  long ret=0;
  int value=0;
  value=array[startOffset - 1] & getLSBMask(bitsRest);
  value=(array[startOffset - 1] < 0) ? (array[startOffset - 1] + 256) : array[startOffset - 1];
  ret=ret | (value << ((array.length - startOffset) * NetUtils.NumBitsInAByte));
  for (int i=startOffset; i < array.length; i++) {
    value=array[i];
    if (value < 0)     value+=256;
    ret=ret | (long)((long)value << ((array.length - i - 1) * NetUtils.NumBitsInAByte));
  }
  return ret;
}