Buggy code:
@ Component @ Path ( "indent" ) public class IndentResource extends BaseResource { @ Context private HttpServletRequest webRequest ; @ Resource private MessageBuilder messageBuilder ; @ Resource private IndentService indentService ; @ Resource private CommodityService commodityService ; @ POST @ Path ( "entity//{commodityId}" ) @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public String create ( @ HeaderParam ( Constants . HEADER_X_AUTH_HEADER ) String token , @ PathParam ( "commodityId" ) String commodityId , String inString ) { SessionContext sessionContext = filterSessionContext ( token , USER ) ; Indent pojo = JsonUtil . getPojoFromJsonString ( inString , Indent . class ) ; Commodity commodity = commodityService . getById ( commodityId ) ; if ( commodity == null ) { String [ ] param = new String [ ] { commodityId } ; throw new com . ntu . igts . exception . ServiceWarningException ( ( "Cannot<seq2seq4repair_space>find<seq2seq4repair_space>commodity<seq2seq4repair_space>for<seq2seq4repair_space>id<seq2seq4repair_space>" + commodityId ) , MessageKeys . COMMODITY_NOT_FOUND_FOR_ID , param ) ; } if ( StringUtil . isEmpty ( pojo . getUserId ( ) ) ) { pojo . setUserId ( sessionContext . getUserId ( ) ) ; } if ( StringUtil . isEmpty ( pojo . getUserName ( ) ) ) { <START_BUG> pojo . setUserId ( sessionContext . getUserName ( ) ) ; <END_BUG> } pojo . setCarriage ( commodity . getCarriage ( ) ) ; pojo . setCommodityId ( commodityId ) ; pojo . setCommodityPrice ( commodity . getPrice ( ) ) ; pojo . setIndentTime ( new Date ( ) ) ; pojo . setIndentPrice ( ( ( pojo . getCarriage ( ) ) + ( pojo . getCommodityPrice ( ) ) ) ) ; pojo . setStatus ( UNPAID . value ( ) ) ; pojo . setIndentNumber ( CommonUtil . getIndentNumber ( ) ) ; Indent insertedIndent = indentService . create ( pojo ) ; return JsonUtil . getJsonStringFromPojo ( insertedIndent ) ; } @ PUT @ Path ( "entity//{status}//{indentId}" ) @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public String update ( @ HeaderParam ( Constants . HEADER_X_AUTH_HEADER ) String token , @ PathParam ( "status" ) IndentStatusEnum statusEnum , @ PathParam ( "indentId" ) String indentId , @ QueryParam ( "paytype" ) PayTypeEnum payTypeEnum ) { } @ PUT @ Path ( "price" ) @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public String updateIndentPrice ( @ HeaderParam ( Constants . HEADER_X_AUTH_HEADER ) String token , String inString ) { } @ PUT @ Path ( "paytype" ) @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public String updatePayType ( @ HeaderParam ( Constants . HEADER_X_AUTH_HEADER ) String token , String inString ) { } @ PUT @ Path ( "status" ) @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public String updateIndentStatus ( @ HeaderParam ( Constants . HEADER_X_AUTH_HEADER ) String token , String inString ) { } @ DELETE @ Path ( "entity//{indentid}" ) @ Produces ( MediaType . TEXT_PLAIN ) public String deleteIndent ( @ HeaderParam ( Constants . HEADER_X_AUTH_HEADER ) String token , @ PathParam ( "indentid" ) String indentId ) { } @ GET @ Path ( "entity//{indentid}" ) @ Produces ( MediaType . APPLICATION_JSON ) public String getIndentById ( @ HeaderParam ( Constants . HEADER_X_AUTH_HEADER ) String token , @ PathParam ( "indentid" ) String indentId ) { } @ GET @ Path ( "entity" ) @ Produces ( MediaType . APPLICATION_JSON ) public String getIndentsForUser ( @ HeaderParam ( Constants . HEADER_X_AUTH_HEADER ) String token , @ QueryParam ( "page" ) int currentPage , @ QueryParam ( "size" ) int pageSize ) { } private Indent checkIndentAvailability ( String indentId ) { } private void checkMoneyNumber ( double ... moneyArray ) { } }

Fix:
pojo . setUserName ( sessionContext . getUserName ( ) ) ;