Author: jleroux Date: Sat Jun 2 18:50:08 2012 New Revision: 1345550 URL: http://svn.apache.org/viewvc?rev=1345550&view=rev Log: "Applied fix from trunk for revision: 1345547 " ------------------------------------------------------------------------ r1345547 | jleroux | 2012-06-02 20:47:41 +0200 (sam., 02 juin 2012) | 8 lines
A patch from Nandani Aggarwal "Upload file throws java.lang.ClassCastException: java.nio.HeapByteBuffer" https://issues.apache.org/jira/browse/OFBIZ-4919 While creating Promo under catalog in Admin , we create Promo Code so that party or Email can be attached to Promo and also there we can set expiry date for that Promo.While uploading list of Email Ids for which Promo will be applicable,,i encountered with error : java.lang.ClassCasrrException:java.nio.HeapByteBuffer. Error can be reproduced by following link : https://localhost:8443/catalog/control/createBulkProductPromoCodeEmail?productPromoCodeId="Name of : Product Promo Code Id" Or with help of attached screenshot. ------------------------------------------------------------------------ Modified: ofbiz/branches/release11.04/ (props changed) ofbiz/branches/release11.04/applications/product/src/org/ofbiz/product/promo/PromoServices.java Propchange: ofbiz/branches/release11.04/ ------------------------------------------------------------------------------ Merged /ofbiz/trunk:r1345547 Modified: ofbiz/branches/release11.04/applications/product/src/org/ofbiz/product/promo/PromoServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/applications/product/src/org/ofbiz/product/promo/PromoServices.java?rev=1345550&r1=1345549&r2=1345550&view=diff ============================================================================== --- ofbiz/branches/release11.04/applications/product/src/org/ofbiz/product/promo/PromoServices.java (original) +++ ofbiz/branches/release11.04/applications/product/src/org/ofbiz/product/promo/PromoServices.java Sat Jun 2 18:50:08 2012 @@ -198,18 +198,21 @@ public class PromoServices { } public static Map<String, Object> importPromoCodeEmailsFromFile(DispatchContext dctx, Map<String, ? extends Object> context) { - LocalDispatcher dispatcher = dctx.getDispatcher(); + LocalDispatcher dispatcher = dctx.getDispatcher(); String productPromoCodeId = (String) context.get("productPromoCodeId"); - byte[] wrapper = (byte[]) context.get("uploadedFile"); GenericValue userLogin = (GenericValue) context.get("userLogin"); Locale locale = (Locale) context.get("locale"); - - if (wrapper == null) { + + ByteBuffer bytebufferwrapper = (ByteBuffer) context.get("uploadedFile"); + + if (bytebufferwrapper == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ProductPromoCodeImportUploadedFileNotValid", locale)); } - // read the bytes into a reader + byte[] wrapper = bytebufferwrapper.array(); + + // read the bytes into a reader BufferedReader reader = new BufferedReader(new StringReader(new String(wrapper))); List<Object> errors = FastList.newInstance(); int lines = 0;

