id
int64
1
49k
buggy
stringlengths
34
37.5k
fixed
stringlengths
2
37k
6,301
encr.prepare(saaj.getSOAPPart(), getEncryptionCrypto(recToken)); if (encr.getBSTTokenId() != null) { encr.prependBSTElementToHeader(secHeader); } <BUG>Element refList = encr.encryptForExternalRef(null, encrParts); this.addDerivedKeyElement(refList); return encr;</BUG> } catch (WSSecurityException e) { policyNotAsserted(recToken, e.getMessage());
if (atEnd) { this.insertBeforeBottomUp(refList); } else { return encr;
6,302
package mobi.cangol.mobile.appcore.demo.appservice; import android.content.Context; import android.content.Intent; import android.net.Uri; <BUG>import android.os.Bundle; import android.support.annotation.Nullable;</BUG> import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater;
import android.os.Parcelable; import android.support.annotation.Nullable;
6,303
class AppDownloadExecutor extends DownloadExecutor<App> { public AppDownloadExecutor(String name) { super(name); } @Override <BUG>protected void add(App app) { this.add(getResource(app)); } @Override protected DownloadResource getResource(App app) { return new DownloadResource(app.url, app.name + ".apk"); }</BUG> @Override
protected DownloadResource getDownloadResource(App app) { DownloadResource downloadResource=new DownloadResource(this.getDownloadDir().getAbsolutePath(),app.url, app.name + ".apk"); FileUtils.delete(downloadResource.getConfFile()); FileUtils.delete(downloadResource.getSourceFile()); return downloadResource;
6,304
<BUG>package mobi.cangol.mobile.appcore.demo; import android.os.Bundle;</BUG> import android.support.v4.app.Fragment; import android.support.v4.app.ListFragment; import android.view.View;
import android.annotation.TargetApi; import android.os.Build; import android.os.Bundle;
6,305
import java.util.ArrayList; import java.util.List; import mobi.cangol.mobile.appcore.demo.appservice.AnalyticsServiceFragment; import mobi.cangol.mobile.appcore.demo.appservice.CacheManagerFragment; import mobi.cangol.mobile.appcore.demo.appservice.ConfigServiceFragment; <BUG>import mobi.cangol.mobile.appcore.demo.appservice.CrashServiceFragment; import mobi.cangol.mobile.appcore.demo.appservice.LocationServiceFragment;</BUG> import mobi.cangol.mobile.appcore.demo.appservice.SessionServiceFragment; import mobi.cangol.mobile.appcore.demo.appservice.StatusServiceFragment; import mobi.cangol.mobile.appcore.demo.appservice.UpgradeServiceFragment;
import mobi.cangol.mobile.appcore.demo.appservice.DownloadManagerFragment; import mobi.cangol.mobile.appcore.demo.appservice.LocationServiceFragment;
6,306
list.add(ConfigServiceFragment.class); list.add(CrashServiceFragment.class); list.add(LocationServiceFragment.class); list.add(SessionServiceFragment.class); list.add(StatusServiceFragment.class); <BUG>list.add(UpgradeServiceFragment.class); }</BUG> @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
list.add(DownloadManagerFragment.class); }
6,307
List<String> listStr=new ArrayList<String>(); for (int i = 0; i < list.size(); i++) { listStr.add(list.get(i).getSimpleName().replace("Fragment","")); } setListAdapter(new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1, listStr)); <BUG>} @Override</BUG> public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); getActivity().setTitle((String)getListAdapter().getItem(position));
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override
6,308
public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); getActivity().setTitle((String)getListAdapter().getItem(position)); ((MainActivity)getActivity()).toFragment(list.get(position)); getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); <BUG>} @Override</BUG> public void onStart() { super.onStart(); getActivity().setTitle("AppService");
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override
6,309
public BlockArmoryInventory (String pBlockName, Material pBlockMaterial) { super(pBlockMaterial); setUnlocalizedName(pBlockName); setHardness(5F); setResistance(10F); <BUG>setRegistryName(References.General.MOD_ID, pBlockName); </BUG> } @Override public void breakBlock (World worldIn, BlockPos pos, IBlockState state) {
setRegistryName(References.General.MOD_ID.toLowerCase(), pBlockName);
6,310
public class ItemMetalRing extends ItemResource implements IHeatableItem { public ItemMetalRing() { this.setMaxStackSize(64); this.setCreativeTab(GeneralRegistry.CreativeTabs.componentsTab); this.setUnlocalizedName(References.InternalNames.Items.ItemMetalRing); <BUG>this.setRegistryName(References.InternalNames.Items.ItemMetalRing); </BUG> } @Override public boolean getHasSubtypes() {
this.setRegistryName(References.InternalNames.Items.ItemMetalRing.toLowerCase());
6,311
public ItemHammer() { setMaxStackSize(1); setMaxDamage(150); setCreativeTab(GeneralRegistry.CreativeTabs.generalTab); setUnlocalizedName(References.InternalNames.Items.ItemHammer); <BUG>setRegistryName(References.InternalNames.Items.ItemHammer); </BUG> addPropertyOverride(CoreReferences.IItemProperties.MODELTYPE, new IItemPropertyGetter() { @Override public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) {
setRegistryName(References.InternalNames.Items.ItemHammer.toLowerCase());
6,312
public class ItemPlate extends ItemResource implements IHeatableItem { public ItemPlate() { this.setMaxStackSize(64); this.setCreativeTab(GeneralRegistry.CreativeTabs.componentsTab); this.setUnlocalizedName(References.InternalNames.Items.ItemMetalPlate); <BUG>this.setRegistryName(References.InternalNames.Items.ItemMetalPlate); </BUG> } @Override public boolean getHasSubtypes() {
this.setRegistryName(References.InternalNames.Items.ItemMetalPlate.toLowerCase());
6,313
public class ItemHeatedItem extends Item { public ItemHeatedItem () { setMaxStackSize(1); setCreativeTab(GeneralRegistry.CreativeTabs.heatedItemTab); setUnlocalizedName(References.InternalNames.Items.ItemHeatedIngot); <BUG>this.setRegistryName(References.General.MOD_ID, References.InternalNames.Items.ItemHeatedIngot); </BUG> } public boolean areStacksEqualExceptTemp (ItemStack pFirstStack, ItemStack pSecondStack) { if (!( pFirstStack.getItem() instanceof ItemHeatedItem )) {
this.setRegistryName(References.General.MOD_ID.toLowerCase(), References.InternalNames.Items.ItemHeatedIngot);
6,314
public boolean shouldRefresh (World world, BlockPos pos, IBlockState oldState, IBlockState newSate) { return oldState.getBlock() != newSate.getBlock(); } public void heatFurnace () { calculateHeatTerms(); <BUG>FirePitState structureState = (FirePitState) getStructureData(); FirePitState tileState = (FirePitState) getState(); tileState.setLastAddedHeat(0F);</BUG> if ((Float) structureState.getData(this, References.NBTTagCompoundData.TE.FirePit.FUELSTACKBURNINGTIME) < 1F) { for (int tFuelStackIndex = 0; tFuelStackIndex < FUELSTACK_AMOUNT; tFuelStackIndex++) {
FirePitState structureState = getStructureData(); FirePitState tileState = getState(); tileState.setLastAddedHeat(0F);
6,315
stackCompound.setFloat(References.NBTTagCompoundData.HeatedIngot.CURRENTTEMPERATURE, pNewTemp); pItemStack.setTagCompound(stackCompound); } } public void meltIngots () { <BUG>FirePitState state = (FirePitState) getState(); for (int i = 0; i < INGOTSTACKS_AMOUNT; i++) {</BUG> ItemStack stack = ingotStacks[i]; if (stack == null) continue;
FirePitState state = getState(); for (int i = 0; i < INGOTSTACKS_AMOUNT; i++) {
6,316
queBlockModelUpdateOnClients(); } @Override public void initiateAsSlaveEntity (Coordinate3D masterLocation) { masterCoordinate = masterLocation; <BUG>slaveCoordinates = new ArrayList<Coordinate3D>(); structureBounds = new Cube(getPos().getX(), getPos().getY(), getPos().getZ(), 0, 0, 0);</BUG> BlockFirePit.setMasterState(false, getWorld(), getPos()); } @Override
slaveCoordinates = new ArrayList<>(); structureBounds = new Cube(getPos().getX(), getPos().getY(), getPos().getZ(), 0, 0, 0);
6,317
super(pInternalName, 1, slotPart); this.setUnlocalizedName(pInternalName); this.setMaxStackSize(1); this.uniqueID = pInternalName; this.setCreativeTab(GeneralRegistry.CreativeTabs.armorTab); <BUG>this.setRegistryName(References.General.MOD_ID, pInternalName); </BUG> } @Override public ISpecialArmor.ArmorProperties getProperties(EntityLivingBase pEntity, ItemStack pStack, DamageSource pSource, double pDamage, int pSlot) {
this.setRegistryName(References.General.MOD_ID.toLowerCase(), pInternalName);
6,318
import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import java.util.*; <BUG>public class TileEntityBlackSmithsAnvil extends TileEntityArmory implements IItemStorage, ITickable { </BUG> public static int MAX_CRAFTINGSLOTS = 25; public static int MAX_OUTPUTSLOTS = 1; public static int MAX_HAMMERSLOTS = 1;
public class TileEntityBlackSmithsAnvil extends TileEntityArmory<BlackSmithsAnvilState, BlackSmithsAnvilGuiManager> implements IItemStorage, ITickable {
6,319
public void setInventorySlotContents(int pSlotID, ItemStack pNewItemStack) { if (pSlotID < 0) return; if (pSlotID < MAX_CRAFTINGSLOTS) { craftingStacks[pSlotID] = pNewItemStack; <BUG>((BlackSmithsAnvilState) getState()).setCraftingprogress(0); findValidRecipe();</BUG> return; } pSlotID -= MAX_CRAFTINGSLOTS;
(getState()).setCraftingprogress(0); findValidRecipe();
6,320
markDirty(); } } } public void findValidRecipe() { <BUG>if (((BlackSmithsAnvilState) getState()).isProcessingCraftingResult()) return;</BUG> setCurrentRecipe(null); if (SmithsCore.isInDevenvironment()) { Armory.getLogger().info("Checking Recipe for:");
if ((getState()).isProcessingCraftingResult()) return;
6,321
if (tongStacks[0].getItemDamage() == 0) { tongStacks[0] = null; } } getCurrentRecipe().onRecipeUsed(this); <BUG>((BlackSmithsAnvilState) getState()).setProcessingCraftingResult(false); }</BUG> public AnvilType getCurrentAnvilType() { boolean DEBUG = false; if (DEBUG)
(getState()).setProcessingCraftingResult(false);
6,322
if (!tFoundCoolingBasin && tFoundHelperRack) return AnvilType.Extended; return AnvilType.Standard; } public Collection<UUID> getWatchingPlayers() { <BUG>return ((BlackSmithsAnvilGuiManager) getManager()).getWatchingPlayers(); }</BUG> public int getConnectedPlayerCount() { return getWatchingPlayers().size(); }
return (getManager()).getWatchingPlayers();
6,323
public ItemTongs() { setMaxStackSize(1); setMaxDamage(150); setCreativeTab(GeneralRegistry.CreativeTabs.generalTab); setUnlocalizedName(References.InternalNames.Items.ItemTongs); <BUG>setRegistryName(References.InternalNames.Items.ItemTongs); </BUG> addPropertyOverride(CoreReferences.IItemProperties.MODELTYPE, new IItemPropertyGetter() { @Override public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) {
setRegistryName(References.InternalNames.Items.ItemTongs.toLowerCase());
6,324
public class ItemNugget extends ItemResource implements IHeatableItem { public ItemNugget() { this.setMaxStackSize(64); this.setCreativeTab(GeneralRegistry.CreativeTabs.componentsTab); this.setUnlocalizedName(References.InternalNames.Items.ItemMetalNugget); <BUG>this.setRegistryName(References.InternalNames.Items.ItemMetalNugget); </BUG> } @Override public boolean getHasSubtypes() {
this.setRegistryName(References.InternalNames.Items.ItemMetalNugget.toLowerCase());
6,325
public class ItemArmorComponent extends Item implements ISingleMaterialItem, ISingleComponentItem { public ItemArmorComponent() { this.setMaxStackSize(1); this.setCreativeTab(GeneralRegistry.CreativeTabs.componentsTab); this.setUnlocalizedName(References.InternalNames.Items.ItemArmorComponent); <BUG>this.setRegistryName(References.General.MOD_ID, References.InternalNames.Items.ItemArmorComponent); </BUG> } @Override public String getMaterialInternalName(ItemStack stack) {
this.setRegistryName(References.General.MOD_ID.toLowerCase(), References.InternalNames.Items.ItemArmorComponent);
6,326
public class ItemMetalChain extends ItemResource implements IHeatableItem { public ItemMetalChain() { this.setMaxStackSize(16); this.setCreativeTab(GeneralRegistry.CreativeTabs.componentsTab); this.setUnlocalizedName(References.InternalNames.Items.ItemMetalChain); <BUG>this.setRegistryName(References.InternalNames.Items.ItemMetalChain); </BUG> } @Override public boolean getHasSubtypes() {
this.setRegistryName(References.InternalNames.Items.ItemMetalChain.toLowerCase());
6,327
public static boolean debugMode = false; @ModConfigProperty(category = "Debug", name = "debugModeGOTG", comment = "Enable/Disable Debug Mode for the Gift Of The Gods") public static boolean debugModeGOTG = false; @ModConfigProperty(category = "Debug", name = "debugModeEnchantments", comment = "Enable/Disable Debug Mode for the Enchantments") public static boolean debugModeEnchantments = false; <BUG>@ModConfigProperty(category = "Weapons", name = "enableSwordsRecipes", comment = "Enable/Disable The ArmorPlus Sword's Recipes") public static boolean enableSwordsRecipes = true; @ModConfigProperty(category = "Weapons", name = "enableBattleAxesRecipes", comment = "Enable/Disable The ArmorPlus Battle Axes's Recipes") public static boolean enableBattleAxesRecipes = true; @ModConfigProperty(category = "Weapons", name = "enableBowsRecipes", comment = "Enable/Disable The ArmorPlus Bows's Recipes") public static boolean enableBowsRecipes = true; @ModConfigProperty(category = "Armors.SuperStarArmor.Effects", name = "enableSuperStarHRegen", comment = "Enable/Disable The Super Star Helmet Regeneration") </BUG> public static boolean enableSuperStarHRegen = true;
@ModConfigProperty(category = "Weapons", name = "enableSwordsRecipes", comment = "Enable/Disable ArmorPlus Sword's Recipes") @ModConfigProperty(category = "Weapons", name = "enableBattleAxesRecipes", comment = "Enable/Disable ArmorPlus Battle Axes's Recipes") @ModConfigProperty(category = "Weapons", name = "enableBowsRecipes", comment = "Enable/Disable ArmorPlus Bows's Recipes")
6,328
float p3y = vertices[nextIndex * 2 + 1]; for (int i = nextIndex(nextIndex); i != previousIndex; i = nextIndex(i)) { if (vertexTypes.get(i) != CONVEX) { float vx = vertices[i * 2]; float vy = vertices[i * 2 + 1]; <BUG>int areaSign1 = computeSpannedAreaSign(p1x, p1y, p2x, p2y, vx, vy); if (areaSign1 >= 0) { int areaSign2 = computeSpannedAreaSign(p2x, p2y, p3x, p3y, vx, vy); if (areaSign2 >= 0) { int areaSign3 = computeSpannedAreaSign(p3x, p3y, p1x, p1y, vx, vy); if (areaSign3 >= 0) return false;</BUG> }
if (computeSpannedAreaSign(p1x, p1y, p2x, p2y, vx, vy) >= 0) { if (computeSpannedAreaSign(p2x, p2y, p3x, p3y, vx, vy) >= 0) { if (computeSpannedAreaSign(p3x, p3y, p1x, p1y, vx, vy) >= 0) return false;
6,329
import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter;</BUG> import java.io.StringWriter; <BUG>import java.io.Writer; import java.util.concurrent.CountDownLatch;</BUG> import processing.core.PApplet; class ProcessHelper { private final String[] cmd; public ProcessHelper(final String... cmd) {
package processing.app.tools.android; import java.io.IOException;
6,330
IOException { return execute(tee, tee); } public ProcessResult execute(final boolean teeOut, final boolean teeErr) throws InterruptedException, IOException { <BUG>final StringWriter stdout = new StringWriter(); final StringWriter stderr = new StringWriter(); </BUG> final long startTime = System.currentTimeMillis();
final StringWriter outWriter = new StringWriter(); final StringWriter errWriter = new StringWriter();
6,331
AndroidTool.toolName, "list", "avds"); final String name; final String target; <BUG>static Device avdEclair = new Device("Processing-Eclair", "Google Inc.:Google APIs:5", 854, 480); static final String AVD_CREATE_ERROR = "An error occurred while running “android create avd”\n"</BUG> + "to set up the default Android emulator. Make sure that the\n"
public static final Device ECLAIR = new Device("Processing-Eclair", "Google Inc.:Google APIs:5", static final String AVD_CREATE_ERROR = "An error occurred while running “android create avd”\n"
6,332
this.name = name; this.target = target; } static boolean checkDefaults() { try { <BUG>if (!avdEclair.exists()) { if (!avdEclair.create()) { Base.showWarning("Android Error", AVD_CREATE_ERROR, null);</BUG> } }
if (!ECLAIR.exists()) { if (!ECLAIR.create()) { Base.showWarning("Android Error", AVD_CREATE_ERROR, null);
6,333
File debugFile = new File("../../../android/core.zip"); if (!debugFile.exists() && Base.isMacOS()) { debugFile = new File("../../../../../../../android/core.zip"); } if (debugFile.exists()) { <BUG>System.out.println("Using version of core.zip from local SVN checkout."); </BUG> return debugFile; } return new File(Base.getSketchbookFolder(), ANDROID_CORE_FILENAME);
System.err.println("Using version of core.zip from local SVN checkout.");
6,334
protected Object doExecute() throws Exception { Set<String> providers = computeProviderListener.getInstalledProviders(); if (providers != null && !providers.isEmpty()) { printComputeProviders(providers,computeServices, "", System.out); } else { <BUG>System.out.print("No providers have been found."); </BUG> } return null; }
System.out.println("No providers have been found.");
6,335
import com.google.gson.JsonParseException; import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; <BUG>import java.util.Map; class ApplicationDeserializer extends GsonDeserializer<List<Connection>> {</BUG> @Override public List<Connection> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { assertJsonObject(json);
import static com.auth0.android.lock.internal.json.Connection.connectionFor; class ApplicationDeserializer extends GsonDeserializer<List<Connection>> {
6,336
final JsonObject connectionJson = connectionsArray.get(i).getAsJsonObject(); requiredValue("name", String.class, connectionJson, context); Type mapType = new TypeToken<Map<String, Object>>() { }.getType(); Map<String, Object> values = context.deserialize(connectionJson, mapType); <BUG>connections.add(new Connection(name, values)); </BUG> } return connections; }
connections.add(connectionFor(name, values));
6,337
import android.support.annotation.StyleRes; import android.util.Log; import com.auth0.android.lock.InitialScreen; import com.auth0.android.lock.SocialButtonStyle; import com.auth0.android.lock.UsernameStyle; <BUG>import com.auth0.android.lock.internal.json.Connection; import com.auth0.android.lock.utils.CustomField;</BUG> import com.auth0.android.lock.views.AuthConfig; import java.util.ArrayList; import java.util.HashSet;
import com.auth0.android.lock.internal.json.DatabaseConnection; import com.auth0.android.lock.internal.json.OAuthConnection; import com.auth0.android.lock.internal.json.PasswordlessConnection; import com.auth0.android.lock.utils.CustomField;
6,338
private static final String TAG = Configuration.class.getSimpleName(); private static final String SHOW_SIGNUP_KEY = "showSignup"; private static final String SHOW_FORGOT_KEY = "showForgot"; private static final String REQUIRES_USERNAME_KEY = "requires_username"; private static final String PASSWORD_POLICY_KEY = "passwordPolicy"; <BUG>private Connection defaultDatabaseConnection; private List<Connection> passwordlessConnections; private List<Connection> socialConnections; private List<Connection> enterpriseConnections; </BUG> private boolean allowLogIn;
private DatabaseConnection defaultDatabaseConnection; private List<PasswordlessConnection> passwordlessConnections; private List<OAuthConnection> socialConnections; private List<OAuthConnection> enterpriseConnections;
6,339
@Nullable public Connection getDatabaseConnection() { return defaultDatabaseConnection; } @Nullable <BUG>public Connection getPasswordlessConnection() { </BUG> if (passwordlessConnections.isEmpty()) { return null; }
public PasswordlessConnection getPasswordlessConnection() {
6,340
return null; } if (passwordlessConnections.size() == 1) { return passwordlessConnections.get(0); } <BUG>Connection connection = null; for (Connection c : passwordlessConnections) { </BUG> if (c.getName().equals("email")) {
PasswordlessConnection connection = null; for (PasswordlessConnection c : passwordlessConnections) {
6,341
} } return connection != null ? connection : passwordlessConnections.get(0); } @NonNull <BUG>public List<Connection> getSocialConnections() { </BUG> return socialConnections; } @NonNull
@Nullable public Connection getDatabaseConnection() { return defaultDatabaseConnection;
6,342
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.DigestOutputStream; import java.security.MessageDigest; <BUG>import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Collections; import java.util.List;</BUG> public final class PatchUtils {
import java.text.DateFormat; import java.util.Date; import java.util.List;
6,343
package org.jboss.as.patching.runner; <BUG>import org.jboss.as.boot.DirectoryStructure; import org.jboss.as.patching.LocalPatchInfo;</BUG> import org.jboss.as.patching.PatchInfo; import org.jboss.as.patching.PatchLogger; import org.jboss.as.patching.PatchMessages;
import static org.jboss.as.patching.runner.PatchUtils.generateTimestamp; import org.jboss.as.patching.CommonAttributes; import org.jboss.as.patching.LocalPatchInfo;
6,344
private static final String PATH_DELIMITER = "/"; public static final byte[] NO_CONTENT = PatchingTask.NO_CONTENT; enum Element { ADDED_BUNDLE("added-bundle"), ADDED_MISC_CONTENT("added-misc-content"), <BUG>ADDED_MODULE("added-module"), BUNDLES("bundles"),</BUG> CUMULATIVE("cumulative"), DESCRIPTION("description"), MISC_FILES("misc-files"),
APPLIES_TO_VERSION("applies-to-version"), BUNDLES("bundles"),
6,345
final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final String value = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { <BUG>case APPLIES_TO_VERSION: builder.addAppliesTo(value); break;</BUG> case RESULTING_VERSION: if(type == Patch.PatchType.CUMULATIVE) {
[DELETED]
6,346
final StringBuilder path = new StringBuilder(); for(final String p : item.getPath()) { path.append(p).append(PATH_DELIMITER); } path.append(item.getName()); <BUG>writer.writeAttribute(Attribute.PATH.name, path.toString()); if(type != ModificationType.REMOVE) {</BUG> writer.writeAttribute(Attribute.HASH.name, bytesToHexString(item.getContentHash())); } if(type != ModificationType.ADD) {
if (item.isDirectory()) { writer.writeAttribute(Attribute.DIRECTORY.name, "true"); if(type != ModificationType.REMOVE) {
6,347
package org.jboss.as.patching; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.patching.runner.PatchingException; import org.jboss.logging.Messages; import org.jboss.logging.annotations.Message; <BUG>import org.jboss.logging.annotations.MessageBundle; import java.io.IOException;</BUG> import java.util.List; @MessageBundle(projectCode = "JBAS") public interface PatchMessages {
import org.jboss.logging.annotations.Cause; import java.io.IOException;
6,348
customTokens.put("%%mlFinalForestsPerHost%%", hubConfig.finalForestsPerHost.toString()); customTokens.put("%%mlTraceAppserverName%%", hubConfig.traceHttpName); customTokens.put("%%mlTracePort%%", hubConfig.tracePort.toString()); customTokens.put("%%mlTraceDbName%%", hubConfig.traceDbName); customTokens.put("%%mlTraceForestsPerHost%%", hubConfig.traceForestsPerHost.toString()); <BUG>customTokens.put("%%mlModulesDbName%%", hubConfig.modulesDbName); }</BUG> public void init() { try { LOGGER.error("PLUGINS DIR: " + pluginsDir.toString());
customTokens.put("%%mlTriggersDbName%%", hubConfig.triggersDbName); customTokens.put("%%mlSchemasDbName%%", hubConfig.schemasDbName); }
6,349
channel.resumeWrites(); } else { channel.getWriteSetter().set(null); channel.shutdownWrites(); } <BUG>} catch (IOException e) { UndertowLogger.REQUEST_IO_LOGGER.ioException(e); IoUtils.safeClose(channel); } catch (Exception e) { UndertowLogger.REQUEST_IO_LOGGER.ioException(new IOException(e)); IoUtils.safeClose(channel);</BUG> }
[DELETED]
6,350
import org.jboss.logging.annotations.MessageBundle; import io.undertow.predicate.PredicateBuilder; import io.undertow.protocols.http2.HpackException; import io.undertow.security.api.AuthenticationMechanism; import io.undertow.server.handlers.builder.HandlerBuilder; <BUG>import io.undertow.util.HttpString; @MessageBundle(projectCode = "UT")</BUG> public interface UndertowMessages { UndertowMessages MESSAGES = Messages.getBundle(UndertowMessages.class); @Message(id = 1, value = "Maximum concurrent requests must be larger than zero.")
import io.undertow.util.ParameterLimitException; @MessageBundle(projectCode = "UT")
6,351
@Message(id = 45, value = "Error parsing predicated handler string %s:%n%s") IllegalArgumentException errorParsingPredicateString(String reason, String s); @Message(id = 46, value = "The number of cookies sent exceeded the maximum of %s") IllegalStateException tooManyCookies(int maxCookies); @Message(id = 47, value = "The number of parameters exceeded the maximum of %s") <BUG>IllegalStateException tooManyParameters(int maxValues); </BUG> @Message(id = 48, value = "No request is currently active") IllegalStateException noRequestActive(); @Message(id = 50, value = "AuthenticationMechanism Outcome is null")
ParameterLimitException tooManyParameters(int maxValues);
6,352
this.maxHeaders = maxHeaders; this.streamId = streamId; } @Override protected void handleData(ByteBuffer resource, Http2FrameHeaderParser header) throws IOException { <BUG>if(maxHeaders > 0 && headerMap.size() >= maxHeaders) { throw new IOException(UndertowMessages.MESSAGES.tooManyHeaders(maxHeaders)); }</BUG> boolean continuationFramesComing = Bits.anyAreClear(header.flags, Http2Channel.HEADERS_FLAG_END_HEADERS); if (frameRemaining == -1) {
[DELETED]
6,353
protected abstract boolean handleBeforeHeader(ByteBuffer resource, Http2FrameHeaderParser header); HeaderMap getHeaderMap() { return headerMap; } @Override <BUG>public void emitHeader(HttpString name, String value, boolean neverIndex) throws HpackException { headerMap.add(name, value);</BUG> if(name.length() == 0) { throw UndertowMessages.MESSAGES.invalidHeader(); }
if(maxHeaders > 0 && headerMap.size() > maxHeaders) { return; headerMap.add(name, value);
6,354
import java.io.Closeable; import java.io.IOException; import java.net.InetSocketAddress; import java.net.URI; import java.util.ArrayDeque; <BUG>import java.util.Deque; import java.util.concurrent.ConcurrentMap;</BUG> import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong;
import java.util.Map; import java.util.concurrent.ConcurrentMap;
6,355
} } this.requiresContinue = reqContinue; } void terminateRequest() { <BUG>state |= REQUEST_TERMINATED; if (anyAreSet(state, RESPONSE_TERMINATED)) {</BUG> clientConnection.requestDone(); } }
if(!clientConnection.isOpen()) { state |= RESPONSE_TERMINATED; if (anyAreSet(state, RESPONSE_TERMINATED)) {
6,356
package io.undertow.server; import io.undertow.UndertowLogger; import io.undertow.UndertowOptions; import io.undertow.server.handlers.Cookie; import io.undertow.util.DateUtils; <BUG>import io.undertow.util.Headers; import io.undertow.util.StatusCodes;</BUG> import io.undertow.util.URLUtils; import io.undertow.connector.PooledByteBuffer; import org.xnio.channels.StreamSourceChannel;
import io.undertow.util.ParameterLimitException; import io.undertow.util.StatusCodes;
6,357
UndertowLogger.REQUEST_LOGGER.undertowRequestFailed(t, exchange); exchange.endExchange(); } } @Deprecated <BUG>public static void setExchangeRequestPath(final HttpServerExchange exchange, final String encodedPath, final String charset, boolean decode, final boolean allowEncodedSlash, StringBuilder decodeBuffer) { setExchangeRequestPath(exchange, encodedPath, charset, decode, allowEncodedSlash, decodeBuffer, exchange.getConnection().getUndertowOptions().get(UndertowOptions.MAX_PARAMETERS, UndertowOptions.DEFAULT_MAX_PARAMETERS)); } public static void setExchangeRequestPath(final HttpServerExchange exchange, final String encodedPath, final String charset, boolean decode, final boolean allowEncodedSlash, StringBuilder decodeBuffer, int maxParameters) { </BUG> boolean requiresDecode = false;
try { } catch (ParameterLimitException e) { throw new RuntimeException(e); public static void setExchangeRequestPath(final HttpServerExchange exchange, final String encodedPath, final String charset, boolean decode, final boolean allowEncodedSlash, StringBuilder decodeBuffer, int maxParameters) throws ParameterLimitException {
6,358
if (values == null) { this.values.put(name, values = new ArrayDeque<>(1)); } values.add(new FormValueImpl(value, headers)); if (++valueCount > maxValues) { <BUG>throw UndertowMessages.MESSAGES.tooManyParameters(maxValues); </BUG> } } public void add(String name, Path value, String fileName, final HeaderMap headers) {
throw new RuntimeException(UndertowMessages.MESSAGES.tooManyParameters(maxValues));
6,359
if (old != null) { valueCount -= old.size(); } values.add(new FormValueImpl(value, headers)); if (++valueCount > maxValues) { <BUG>throw UndertowMessages.MESSAGES.tooManyParameters(maxValues); </BUG> } } public Deque<FormValue> remove(String name) {
throw new RuntimeException(UndertowMessages.MESSAGES.tooManyParameters(maxValues));
6,360
import static io.undertow.protocols.ajp.AjpConstants.ATTR_SSL_KEY_SIZE; import static io.undertow.protocols.ajp.AjpConstants.ATTR_SSL_SESSION; import static io.undertow.protocols.ajp.AjpConstants.ATTR_STORED_METHOD; import static io.undertow.protocols.ajp.AjpUtils.notNull; import static io.undertow.protocols.ajp.AjpUtils.putString; <BUG>import java.io.IOException; import java.nio.ByteBuffer; import io.undertow.UndertowOptions; import io.undertow.util.ImmediatePooledByteBuffer; import org.xnio.ChannelListener;</BUG> import io.undertow.connector.PooledByteBuffer;
import java.nio.BufferOverflowException; import org.xnio.ChannelListener; import io.undertow.UndertowMessages; import io.undertow.client.ProxiedRequestAttachments;
6,361
import io.undertow.server.protocol.framed.SendFrameHeader; import io.undertow.util.Attachable; import io.undertow.util.FlexBase64; import io.undertow.util.HeaderMap; import io.undertow.util.Headers; <BUG>import io.undertow.util.HttpString; public class AjpClientRequestClientStreamSinkChannel extends AbstractAjpClientStreamSinkChannel {</BUG> private final ChannelListener<AjpClientRequestClientStreamSinkChannel> finishListener; private static final int DEFAULT_MAX_DATA_SIZE = 8192; private final HeaderMap headers;
import io.undertow.util.ImmediatePooledByteBuffer; public class AjpClientRequestClientStreamSinkChannel extends AbstractAjpClientStreamSinkChannel {
6,362
this.method = method; this.protocol = protocol; this.attachable = attachable; } private SendFrameHeader createFrameHeaderImpl() { <BUG>if(discardMode) { </BUG> getBuffer().clear(); getBuffer().flip(); return new SendFrameHeader(new ImmediatePooledByteBuffer(ByteBuffer.wrap(new byte[0])));
if (discardMode) {
6,363
import io.undertow.util.HeaderMap; import io.undertow.util.Headers; import io.undertow.util.HttpString; import io.undertow.util.Methods; import org.xnio.ChannelListener; <BUG>import io.undertow.connector.PooledByteBuffer; import org.xnio.StreamConnection;</BUG> import org.xnio.channels.StreamSinkChannel; import org.xnio.channels.StreamSourceChannel; import org.xnio.conduits.ConduitStreamSinkChannel;
import io.undertow.util.StatusCodes; import org.xnio.StreamConnection;
6,364
if(scheme != null) { httpServerExchange.setRequestScheme(scheme); } if(state.attributes != null) { httpServerExchange.putAttachment(HttpServerExchange.REQUEST_ATTRIBUTES, state.attributes); <BUG>} state = null;</BUG> this.httpServerExchange = null; httpServerExchange.setPersistent(true); if(recordRequestStartTime) {
AjpRequestParseState oldState = state; state = null;
6,365
private ODataRequest processQueryOperation(final BatchBodyPart bodyPart, final String baseUri, final BatchQueryOperation queryOperation) throws BatchDeserializerException { if (bodyPart.isChangeSet()) { BatchQueryOperation encapsulatedQueryOperation = ((BatchChangeSetPart) queryOperation).getRequest(); handleContentId(queryOperation, encapsulatedQueryOperation); <BUG>validateHeader(queryOperation, true); </BUG> return createRequest(encapsulatedQueryOperation, baseUri, bodyPart.isChangeSet()); } else { return createRequest(queryOperation, baseUri, bodyPart.isChangeSet());
validateHeaders(queryOperation.getHeaders(), false);
6,366
throw new BatchDeserializerException("Forbidden header", MessageKeys.FORBIDDEN_HEADER, Integer.toString(header.getLineNumber())); } } private InputStream getBodyStream(final BatchQueryOperation operation, final HttpRequestStatusLine statusLine, <BUG>final Charset charset) throws BatchDeserializerException { </BUG> if (statusLine.getMethod().equals(HttpMethod.GET)) { return new ByteArrayInputStream(new byte[0]);
final Charset charset) throws BatchDeserializerException {
6,367
import org.apache.olingo.commons.api.http.HttpMethod; import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerException; import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerException.MessageKeys; public class HttpRequestStatusLine { private static final Pattern PATTERN_RELATIVE_URI = Pattern.compile("([^/][^?]*)(?:\\?(.*))?"); <BUG>private static final Set<String> HTTP_CHANGE_SET_METHODS = new HashSet<String>(Arrays.asList(new String[] { "POST", "PUT", "DELETE", "PATCH" })); private static final String HTTP_VERSION = "HTTP/1.1";</BUG> final private Line statusLine;
private static final Set<HttpMethod> HTTP_CHANGE_SET_METHODS = new HashSet<HttpMethod>(Arrays.asList( new HttpMethod[] { HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE, HttpMethod.PATCH })); private static final String HTTP_VERSION = "HTTP/1.1";
6,368
public class BatchLineReader { private static final byte CR = '\r'; private static final byte LF = '\n'; private static final int EOF = -1; private static final int BUFFER_SIZE = 8192; <BUG>private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); private static final Charset CS_ISO_8859_1 = Charset.forName("iso-8859-1");</BUG> public static final String BOUNDARY = "boundary"; public static final String DOUBLE_DASH = "--";
private static final Charset DEFAULT_CHARSET = Charset.forName("ISO-8859-1");
6,369
readState.foundBoundary(); } } } private boolean isBoundary(final String currentLine) { <BUG>if ((currentBoundary + CRLF).equals(currentLine)) { return true; } else if ((currentBoundary + DOUBLE_DASH + CRLF).equals(currentLine)) { return true; } return false;</BUG> }
return (currentBoundary + CRLF).equals(currentLine) || (currentBoundary + DOUBLE_DASH + CRLF).equals(currentLine);
6,370
protected static final String BOUNDARY = "boundary"; public static final String BINARY_ENCODING = "binary"; private BatchParserCommon() { /* private constructor for helper class */ } public static String getBoundary(final String contentType, final int line) throws BatchDeserializerException { final ContentType type = parseContentType(contentType, ContentType.MULTIPART_MIXED, line); <BUG>String boundary = type.getParameter(BOUNDARY); </BUG> if (boundary == null) { throw new BatchDeserializerException("Missing boundary.", BatchDeserializerException.MessageKeys.MISSING_BOUNDARY_DELIMITER, Integer.toString(line));
final String boundary = type.getParameter(BOUNDARY);
6,371
INVALID_CONTENT, INVALID_CONTENT_LENGTH, INVALID_CONTENT_TRANSFER_ENCODING, INVALID_CONTENT_TYPE, UNEXPECTED_CONTENT_TYPE, <BUG>INVALID_CONTENT_ID, INVALID_HTTP_VERSION,</BUG> INVALID_METHOD, INVALID_STATUS_LINE, INVALID_URI,
INVALID_HOST, INVALID_HTTP_VERSION,
6,372
import org.apache.olingo.client.api.communication.request.batch.ODataChangeset; import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest; import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest; import org.apache.olingo.client.api.communication.request.cud.UpdateType; import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest; <BUG>import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest; import org.apache.olingo.client.api.communication.response.ODataBatchResponse;</BUG> import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse; import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse; import org.apache.olingo.client.api.communication.response.ODataResponse;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest; import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityCreateRequest; import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
6,373
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse; import org.apache.olingo.client.api.communication.response.ODataResponse; import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse; import org.apache.olingo.client.api.domain.ClientEntity; import org.apache.olingo.client.api.domain.ClientEntitySet; <BUG>import org.apache.olingo.client.api.domain.ClientObjectFactory; import org.apache.olingo.client.api.http.HttpClientException; import org.apache.olingo.client.api.uri.URIBuilder; import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;</BUG> import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.client.api.domain.ClientProperty;
6,374
getClient().getConfiguration().setContinueOnError(false); } @Test public void badRequestInChangeSet() { ClientObjectFactory factory = getFactory(); <BUG>final ClientEntity entity = factory.newEntity(ES_NOT_AVAILABLE); entity.getProperties().add(factory.newPrimitiveProperty(PROPERTY_STRING, factory .newPrimitiveValueBuilder() .buildString("1"))); final ODataBatchRequest batchRequest = getClient().getBatchRequestFactory().getBatchRequest(SERVICE_URI); final BatchManager payloadManager = batchRequest.payloadManager();</BUG> final ODataChangeset changeset = payloadManager.addChangeset();
entity.getProperties().add( factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("1"))); BatchManager payloadManager = getClient().getBatchRequestFactory().getBatchRequest(SERVICE_URI).payloadManager();
6,375
assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), updateResponse.getStatusCode()); assertContentType(updateResponse.getContentType()); } @Test public void emptyBatchRequest() { <BUG>final ODataBatchRequest request = getClient().getBatchRequestFactory().getBatchRequest(SERVICE_URI); final BatchManager payload = request.payloadManager(); final ODataBatchResponse response = payload.getResponse(); assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());</BUG> assertEquals("Accepted", response.getStatusMessage());
setCookieHeader(request); final ODataBatchResponse response = request.payloadManager().getResponse(); saveCookieHeader(response); assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
6,376
.get(0) .getProperty("PropertyInt16") .getPrimitiveValue() .toValue()); } <BUG>@Test public void changesetBatchRequest() throws URISyntaxException { final ODataBatchRequest request = getClient().getBatchRequestFactory().getBatchRequest(SERVICE_URI); final BatchManager payload = request.payloadManager(); appendGetRequest(payload, "ESAllPrim", 32767, false); // Without error</BUG> final ODataChangeset changeset = payload.addChangeset();
public void changesetBatchRequest() { BatchManager payload = getClient().getBatchRequestFactory().getBatchRequest(SERVICE_URI).payloadManager(); payload.addRequest(createGetRequest("ESAllPrim", 32767, false));
6,377
final ODataBatchRequest request = getClient().getBatchRequestFactory().getBatchRequest(SERVICE_URI); final BatchManager payload = request.payloadManager(); appendGetRequest(payload, "ESAllPrim", 32767, false); // Without error</BUG> final ODataChangeset changeset = payload.addChangeset(); <BUG>URIBuilder targetURI = getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim"); URI editLink = targetURI.build();</BUG> ClientObjectFactory factory = getFactory(); ClientEntity postEntity = factory.newEntity(new FullQualifiedName(SERVICE_NAMESPACE, "ETAllPrim"));
.get(0) .getProperty("PropertyInt16") .getPrimitiveValue() .toValue()); } @Test public void changesetBatchRequest() { BatchManager payload = getClient().getBatchRequestFactory().getBatchRequest(SERVICE_URI).payloadManager(); payload.addRequest(createGetRequest("ESAllPrim", 32767, false)); URI targetURI = getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim").build();
6,378
assertTrue(item.hasNext()); final ODataResponse response0 = item.next(); assertTrue(response0 instanceof ODataRetrieveResponse); @SuppressWarnings("unchecked") ODataRetrieveResponse<ClientEntity> retrieveResponse = (ODataRetrieveResponse<ClientEntity>) response0; <BUG>assertEquals(34, retrieveResponse.getBody() </BUG> .getProperty("PropertyDecimal") .getPrimitiveValue() .toValue());
assertShortOrInt(34, retrieveResponse.getBody()
6,379
public ReportElement getBase() { return base; } @Override public float print(PDDocument document, PDPageContentStream stream, int pageNumber, float startX, float startY, float allowedWidth) throws IOException { <BUG>PDPage currPage = (PDPage) document.getDocumentCatalog().getPages().get(pageNo); PDPageContentStream pageStream = new PDPageContentStream(document, currPage, true, false); </BUG> base.print(document, pageStream, pageNo, x, y, width); pageStream.close();
PDPage currPage = document.getDocumentCatalog().getPages().get(pageNo); PDPageContentStream pageStream = new PDPageContentStream(document, currPage, PDPageContentStream.AppendMode.APPEND, false);
6,380
public PdfTextStyle(String config) { Assert.hasText(config); String[] split = config.split(","); Assert.isTrue(split.length == 3, "config must look like: 10,Times-Roman,#000000"); fontSize = Integer.parseInt(split[0]); <BUG>font = resolveStandard14Name(split[1]); color = new Color(Integer.valueOf(split[2].substring(1), 16));</BUG> } public int getFontSize() { return fontSize;
font = getFont(split[1]); color = new Color(Integer.valueOf(split[2].substring(1), 16));
6,381
package cc.catalysts.boot.report.pdf.elements; import cc.catalysts.boot.report.pdf.config.PdfTextStyle; import cc.catalysts.boot.report.pdf.utils.ReportAlignType; import org.apache.pdfbox.pdmodel.PDPageContentStream; <BUG>import org.apache.pdfbox.pdmodel.font.PDFont; import org.slf4j.Logger;</BUG> import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; import java.io.IOException;
import org.apache.pdfbox.pdmodel.font.PDType1Font; import org.apache.pdfbox.util.Matrix; import org.slf4j.Logger;
6,382
addTextSimple(stream, textConfig, textX, nextLineY, ""); return nextLineY; } try { <BUG>String[] split = splitText(textConfig.getFont(), textConfig.getFontSize(), allowedWidth, fixedText); </BUG> float x = calculateAlignPosition(textX, align, textConfig, allowedWidth, split[0]); if (!underline) { addTextSimple(stream, textConfig, x, nextLineY, split[0]); } else {
String[] split = splitText(textConfig.getFont(), textConfig.getFontSize(), allowedWidth, text);
6,383
public static void addTextSimple(PDPageContentStream stream, PdfTextStyle textConfig, float textX, float textY, String text) { try { stream.setFont(textConfig.getFont(), textConfig.getFontSize()); stream.setNonStrokingColor(textConfig.getColor()); stream.beginText(); <BUG>stream.newLineAtOffset(textX, textY); stream.showText(text);</BUG> } catch (Exception e) { LOG.warn("Could not add text: " + e.getClass() + " - " + e.getMessage()); }
stream.setTextMatrix(new Matrix(1,0,0,1, textX, textY)); stream.showText(text);
6,384
public static void addTextSimpleUnderlined(PDPageContentStream stream, PdfTextStyle textConfig, float textX, float textY, String text) { addTextSimple(stream, textConfig, textX, textY, text); try { float lineOffset = textConfig.getFontSize() / 8F; stream.setStrokingColor(textConfig.getColor()); <BUG>stream.setLineWidth(0.5F); stream.drawLine(textX, textY - lineOffset, textX + getTextWidth(textConfig.getFont(), textConfig.getFontSize(), text), textY - lineOffset); </BUG> stream.stroke(); } catch (IOException e) {
stream.moveTo(textX, textY - lineOffset); stream.lineTo(textX + getTextWidth(textConfig.getFont(), textConfig.getFontSize(), text), textY - lineOffset);
6,385
list.add(text.length()); return list; } public static String[] splitText(PDFont font, int fontSize, float allowedWidth, String text) { String endPart = ""; <BUG>String shortenedText = text; List<String> breakSplitted = Arrays.asList(shortenedText.split("(\\r\\n)|(\\n)|(\\n\\r)")).stream().collect(Collectors.toList()); if (breakSplitted.size() > 1) {</BUG> String[] splittedFirst = splitText(font, fontSize, allowedWidth, breakSplitted.get(0)); StringBuilder remaining = new StringBuilder(splittedFirst[1] == null ? "" : splittedFirst[1] + "\n");
List<String> breakSplitted = Arrays.asList(text.split("(\\r\\n)|(\\n)|(\\n\\r)")).stream().collect(Collectors.toList()); if (breakSplitted.size() > 1) {
6,386
package cc.catalysts.boot.report.pdf.elements; import org.apache.pdfbox.pdmodel.PDDocument; <BUG>import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; import java.io.IOException;</BUG> import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList;
import org.apache.pdfbox.pdmodel.PDPageContentStream; import java.io.IOException;
6,387
public ReportElement getBase() { return base; } @Override public float print(PDDocument document, PDPageContentStream stream, int pageNumber, float startX, float startY, float allowedWidth) throws IOException { <BUG>PDPage currPage = (PDPage) document.getDocumentCatalog().getPages().get(pageNo); PDPageContentStream pageStream = new PDPageContentStream(document, currPage, true, false); </BUG> base.print(document, pageStream, pageNo, x, y, width); pageStream.close();
PDPage currPage = document.getDocumentCatalog().getPages().get(pageNo); PDPageContentStream pageStream = new PDPageContentStream(document, currPage, PDPageContentStream.AppendMode.APPEND, false);
6,388
public PdfTextStyle(String config) { Assert.hasText(config); String[] split = config.split(","); Assert.isTrue(split.length == 3, "config must look like: 10,Times-Roman,#000000"); fontSize = Integer.parseInt(split[0]); <BUG>font = resolveStandard14Name(split[1]); color = new Color(Integer.valueOf(split[2].substring(1), 16));</BUG> } public int getFontSize() { return fontSize;
font = getFont(split[1]); color = new Color(Integer.valueOf(split[2].substring(1), 16));
6,389
package cc.catalysts.boot.report.pdf.elements; import cc.catalysts.boot.report.pdf.config.PdfTextStyle; import cc.catalysts.boot.report.pdf.utils.ReportAlignType; import org.apache.pdfbox.pdmodel.PDPageContentStream; <BUG>import org.apache.pdfbox.pdmodel.font.PDFont; import org.slf4j.Logger;</BUG> import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; import java.io.IOException;
import org.apache.pdfbox.pdmodel.font.PDType1Font; import org.apache.pdfbox.util.Matrix; import org.slf4j.Logger;
6,390
addTextSimple(stream, textConfig, textX, nextLineY, ""); return nextLineY; } try { <BUG>String[] split = splitText(textConfig.getFont(), textConfig.getFontSize(), allowedWidth, fixedText); </BUG> float x = calculateAlignPosition(textX, align, textConfig, allowedWidth, split[0]); if (!underline) { addTextSimple(stream, textConfig, x, nextLineY, split[0]); } else {
String[] split = splitText(textConfig.getFont(), textConfig.getFontSize(), allowedWidth, text);
6,391
public static void addTextSimple(PDPageContentStream stream, PdfTextStyle textConfig, float textX, float textY, String text) { try { stream.setFont(textConfig.getFont(), textConfig.getFontSize()); stream.setNonStrokingColor(textConfig.getColor()); stream.beginText(); <BUG>stream.newLineAtOffset(textX, textY); stream.showText(text);</BUG> } catch (Exception e) { LOG.warn("Could not add text: " + e.getClass() + " - " + e.getMessage()); }
stream.setTextMatrix(new Matrix(1,0,0,1, textX, textY)); stream.showText(text);
6,392
public static void addTextSimpleUnderlined(PDPageContentStream stream, PdfTextStyle textConfig, float textX, float textY, String text) { addTextSimple(stream, textConfig, textX, textY, text); try { float lineOffset = textConfig.getFontSize() / 8F; stream.setStrokingColor(textConfig.getColor()); <BUG>stream.setLineWidth(0.5F); stream.drawLine(textX, textY - lineOffset, textX + getTextWidth(textConfig.getFont(), textConfig.getFontSize(), text), textY - lineOffset); </BUG> stream.stroke(); } catch (IOException e) {
stream.moveTo(textX, textY - lineOffset); stream.lineTo(textX + getTextWidth(textConfig.getFont(), textConfig.getFontSize(), text), textY - lineOffset);
6,393
list.add(text.length()); return list; } public static String[] splitText(PDFont font, int fontSize, float allowedWidth, String text) { String endPart = ""; <BUG>String shortenedText = text; List<String> breakSplitted = Arrays.asList(shortenedText.split("(\\r\\n)|(\\n)|(\\n\\r)")).stream().collect(Collectors.toList()); if (breakSplitted.size() > 1) {</BUG> String[] splittedFirst = splitText(font, fontSize, allowedWidth, breakSplitted.get(0)); StringBuilder remaining = new StringBuilder(splittedFirst[1] == null ? "" : splittedFirst[1] + "\n");
List<String> breakSplitted = Arrays.asList(text.split("(\\r\\n)|(\\n)|(\\n\\r)")).stream().collect(Collectors.toList()); if (breakSplitted.size() > 1) {
6,394
package cc.catalysts.boot.report.pdf.elements; import org.apache.pdfbox.pdmodel.PDDocument; <BUG>import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; import java.io.IOException;</BUG> import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList;
import org.apache.pdfbox.pdmodel.PDPageContentStream; import java.io.IOException;
6,395
@Override public String getValue() { return strValue; } <BUG>public void setValue(Object value, String strValue) { this.value = (value != null) ? value : strValue;</BUG> this.strValue = (strValue != null) ? strValue : (String) value;
[DELETED]
6,396
public String setName(String name) throws IllegalArgumentException, NullPointerException { if (this.name != null && this.name.equals(name)) return this.name; Toolbox.checkValidXmlName(name); <BUG>return setName(null, null, name); }</BUG> @Override public abstract String getValue(); @Override
return setNameIntern(name); }
6,397
{ setValue(nodeValue); } @Override public void setTextContent(String textContent) throws DOMException <BUG>{ }</BUG> @Override public String getTextContent() throws DOMException {
return name; public final String getNodeName()
6,398
@Override public String getTextContent() throws DOMException { <BUG>return super.getTextContent(); } protected String setName(String namespaceUri, String localName, String name) throws IllegalArgumentException, NullPointerException { if ((this.name != null && this.name.equals(name)) && (getNamespaceURI() != null && getNamespaceURI().equals(namespaceUri))) return this.name; validateNameChangeWithParent(namespaceUri, localName, name);</BUG> String old = getName();
public boolean isId() return false;
6,399
BackboneElement parent = (BackboneElement) getOwnerElement(); if (parent == null) { setValue(value, value); <BUG>return; } String namespaceUri = getNamespaceURI();</BUG> String localName = getLocalName(); AttributeDescriptor descriptor = parent.getAttributeDescriptorOrFail(
else String namespaceUri = getNamespaceURI();
6,400
String localName = getLocalName(); AttributeDescriptor descriptor = parent.getAttributeDescriptorOrFail( namespaceUri, localName, name); NativeAndStringValuePair verified = new NativeAndStringValuePair(value); if ((value != null) && descriptor.verifyAndConvert(parent, verified)) <BUG>{ setValue(verified.value, verified.strValue);</BUG> if (descriptor.hasCustomAction()) descriptor.customAction(parent, this, this); }
assertWritable(this, descriptor); setValue(verified.value, verified.strValue);