Buggy code:
public class PagingLinksFinder { private static final RegExp REG_NEXT_LINK = RegExp . compile ( "(next|weiter|continue|>([^\\|]|$)|»([^\\|]|$))" , "i" ) ; private static final RegExp REG_PREV_LINK = RegExp . compile ( "(prev|early|old|new|<|«)" , "i" ) ; private static final RegExp REG_POSITIVE = RegExp . compile ( "article|body|content|entry|hentry|main|page|pagination|post|text|blog|story" , "i" ) ; private static final RegExp REG_NEGATIVE = RegExp . compile ( ( "combx|comment|com-|contact|foot|footer|footnote|masthead|media|meta" + ( "|outbrain|promo|related|shoutbox|sidebar|sponsor|shopping|tags" + "|tool|widget" ) ) , "i" ) ; private static final RegExp REG_EXTRANEOUS = RegExp . compile ( ( "print|archive|comment|discuss|e[\\-]?mail|share|reply|all|login|sign|single" + "|as<seq2seq4repair_space>one|article" ) , "i" ) ; private static final RegExp REG_PAGINATION = RegExp . compile ( "pag(e|ing|inat)" , "i" ) ; private static final RegExp REG_LINK_PAGINATION = RegExp . compile ( "p(a|g|ag)?(e|ing|ination)?(=|\\//)[0-9]{1,2}$" , "i" ) ; private static final RegExp REG_FIRST_LAST = RegExp . compile ( "(first|last)" , "i" ) ; private static final RegExp REG_PAGE_NUMBER = RegExp . compile ( "((_|-)?p[a-z]*|(_|-))[0-9]{1,2}$" , "gi" ) ; private static final RegExp REG_HREF_CLEANER = RegExp . compile ( "//?(#.*)?$" ) ; public static PaginationInfo getPaginationInfo ( String original_url ) { } public static String findNext ( Element root , String original_url ) { } public static String findPrevious ( Element root , String original_url ) { } private static String findPagingLink ( Element root , String original_url , PagingLinksFinder . PageLink pageLink ) { } public static String getBaseUrlForRelative ( Element root , String original_url ) { } public static AnchorElement createAnchorWithBase ( String base_url ) { Document doc = DomUtil . createHTMLDocument ( Document . get ( ) ) ; BaseElement base = doc . createBaseElement ( ) ; base . setHref ( base_url ) ; doc . getHead ( ) . appendChild ( base ) ; AnchorElement a = doc . createAnchorElement ( ) ; <START_BUG> doc . getBody ( ) . appendChild ( base ) ; <END_BUG> return a ; } private static String fixMissingScheme ( String url ) { } public static String resolveLinkHref ( AnchorElement link , AnchorElement baseAnchor ) { } public static String resolveLinkHref ( String linkHref , AnchorElement baseAnchor ) { } private static String getScheme ( String url ) { } private static String getHostname ( String url ) { } private static String getPath ( String url ) { } private static String findBaseUrl ( String original_url ) { } private static String reverseJoin ( List < String > array , String delim ) { } public static Integer pageDiff ( String url , String linkHref , AnchorElement link , int skip ) { } private static void appendDbgStrForLink ( Element link , String message ) { } private static void logDbgInfoToConsole ( PagingLinksFinder . PageLink pageLink , String pagingHref , NodeList < Element > allLinks ) { } private static class PagingLinkObj { private int mLinkIndex = - 1 ; private int mScore = 0 ; private String mLinkText ; private final String mLinkHref ; PagingLinkObj ( int linkIndex , int score , String linkText , String linkHref ) { } } private enum PageLink { NEXT , PREV ; } private static final Map < Element , String > mLinkDebugInfo = new HashMap < Element , String > ( ) ; }

Fix:
doc . getBody ( ) . appendChild ( a ) ;