id int64 1 49k | buggy stringlengths 34 37.5k | fixed stringlengths 2 37k |
|---|---|---|
18,301 | 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);
|
18,302 | 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));
|
18,303 | 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;
|
18,304 | 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);
|
18,305 | 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);
|
18,306 | 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);
|
18,307 | 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) {
|
18,308 | 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;
|
18,309 | MediaType contentType = ProtobufHttpMessageConverter.PROTOBUF;
this.converter.write(this.testMsg, contentType, outputMessage);
assertEquals(contentType, outputMessage.getHeaders().getContentType());
assertTrue(outputMessage.getBodyAsBytes().length > 0);
Message result = Msg.parseFrom(outputMessage.getBodyAsBytes());
<BUG>assertEquals(this.testMsg, result);
String messageHeader = outputMessage.getHeaders().getFirst(ProtobufHttpMessageConverter.X_PROTOBUF_MESSAGE_HEADER);
assertEquals("Msg", messageHeader);
String schemaHeader = outputMessage.getHeaders().getFirst(ProtobufHttpMessageConverter.X_PROTOBUF_SCHEMA_HEADER);
assertEquals("sample.proto", schemaHeader);</BUG>
}
| String messageHeader =
String schemaHeader =
assertEquals("sample.proto", schemaHeader);
|
18,310 | import java.util.concurrent.ConcurrentHashMap;
import com.google.protobuf.ExtensionRegistry;
import com.google.protobuf.Message;
import com.google.protobuf.TextFormat;
import com.googlecode.protobuf.format.HtmlFormat;
<BUG>import com.googlecode.protobuf.format.JsonFormat;
import com.googlecode.protobuf.format.XmlFormat;
import org.springframework.http.HttpHeaders;</BUG>
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
| import com.googlecode.protobuf.format.ProtobufFormatter;
|
18,311 | import org.springframework.util.FileCopyUtils;
public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<Message> {
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
public static final MediaType PROTOBUF = new MediaType("application", "x-protobuf", DEFAULT_CHARSET);
public static final String X_PROTOBUF_SCHEMA_HEADER = "X-Protobuf-Schema";
<BUG>public static final String X_PROTOBUF_MESSAGE_HEADER = "X-Protobuf-Message";
private static final ConcurrentHashMap<Class<?>, Method> methodCache = new ConcurrentHashMap<Class<?>, Method>();
private ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance();
</BUG>
public ProtobufHttpMessageConverter() {
| private static final ProtobufFormatter JSON_FORMAT = new JsonFormat();
private static final ProtobufFormatter XML_FORMAT = new XmlFormat();
private static final ProtobufFormatter HTML_FORMAT = new HtmlFormat();
private final ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance();
|
18,312 | package com.example.mapdemo;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
<BUG>import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Polygon;</BUG>
import com.google.android.gms.maps.model.PolygonOptions;
import android.graphics.Color;
| import com.google.android.gms.maps.model.Dash;
import com.google.android.gms.maps.model.Dot;
import com.google.android.gms.maps.model.Gap;
import com.google.android.gms.maps.model.JointType;
import com.google.android.gms.maps.model.PatternItem;
import com.google.android.gms.maps.model.Polygon;
|
18,313 | package com.classic.car.ui.base;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import butterknife.ButterKnife;
<BUG>import com.classic.core.fragment.BaseFragment;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription;</BUG>
public abstract class AppBaseFragment extends BaseFragment {
protected Context mAppContext;
| import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import rx.subscriptions.CompositeSubscription;
|
18,314 | @Override public void unRegister() {
if (null != mCompositeSubscription) {
mCompositeSubscription.unsubscribe();
}
}
<BUG>public void addSubscription(Subscription subscription) {
</BUG>
if (null == mCompositeSubscription) {
mCompositeSubscription = new CompositeSubscription();
}
| protected void addSubscription(Subscription subscription) {
|
18,315 | @Override public void unRegister() {
if (null != mCompositeSubscription) {
mCompositeSubscription.unsubscribe();
}
}
<BUG>public void addSubscription(Subscription subscription) {
</BUG>
if (null == mCompositeSubscription) {
mCompositeSubscription = new CompositeSubscription();
}
| protected void addSubscription(Subscription subscription) {
|
18,316 | data.setValueTextSize(8f);
data.setValueTextColor(Color.WHITE);
return data;
}
public static void saveCharts(Activity context, Chart chart){
<BUG>final String fileName = new StringBuilder("charts_")
.append(DateUtil.formatDate("yyyy-MM-dd_HH:mm:ss", System.currentTimeMillis())).toString();
final String path = new StringBuilder().append(File.separator)
.append(AppInfoUtil.getPackageName(context.getApplicationContext()))
.append(File.separator)
.append("images")
.append(File.separator)</BUG>
.toString();
| final String fileName = new StringBuilder("CarAssistant_")
.append(DateUtil.formatDate("yyyy-MM-dd_HH:mm:ss", System.currentTimeMillis()))
.append(".png")
|
18,317 | import com.classic.car.ui.adapter.ConsumerDetailAdapter;
import com.classic.car.ui.base.AppBaseFragment;
import com.classic.core.utils.ToastUtil;
import com.melnykov.fab.FloatingActionButton;
import javax.inject.Inject;
<BUG>import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;</BUG>
public class MainFragment extends AppBaseFragment
implements CommonRecyclerAdapter.OnItemClickListener, CommonRecyclerAdapter.OnItemLongClickListener {
@BindView(R.id.main_recycler_view) RecyclerView mRecyclerView;
| [DELETED] |
18,318 | import rx.schedulers.Schedulers;</BUG>
public class MainFragment extends AppBaseFragment
implements CommonRecyclerAdapter.OnItemClickListener, CommonRecyclerAdapter.OnItemLongClickListener {
@BindView(R.id.main_recycler_view) RecyclerView mRecyclerView;
@BindView(R.id.main_fab) FloatingActionButton mFab;
<BUG>@Inject ConsumerDao mConsumerDao;
</BUG>
private ConsumerDetailAdapter mAdapter;
public static MainFragment newInstance() {
return new MainFragment();
| import com.classic.car.ui.adapter.ConsumerDetailAdapter;
import com.classic.car.ui.base.AppBaseFragment;
import com.classic.core.utils.ToastUtil;
import com.melnykov.fab.FloatingActionButton;
import javax.inject.Inject;
@Inject ConsumerDao mConsumerDao;
|
18,319 | }
@Override public int getLayoutResId() {
return R.layout.fragment_main;
}
@Override public void initView(View parentView, Bundle savedInstanceState) {
<BUG>((CarApplication)activity.getApplicationContext()).getAppComponent().inject(this);
</BUG>
super.initView(parentView, savedInstanceState);
mRecyclerView.setLayoutManager(new LinearLayoutManager(mAppContext));
mAdapter = new ConsumerDetailAdapter(mAppContext, R.layout.item_consumer_detail);
| ((CarApplication) activity.getApplicationContext()).getAppComponent().inject(this);
|
18,320 | mAdapter = new ConsumerDetailAdapter(mAppContext, R.layout.item_consumer_detail);
mRecyclerView.setAdapter(mAdapter);
mAdapter.setOnItemClickListener(this);
mAdapter.setOnItemLongClickListener(this);
mFab.attachToRecyclerView(mRecyclerView);
<BUG>addSubscription(mConsumerDao.queryAll()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.unsubscribeOn(Schedulers.io())
.subscribe(mAdapter));</BUG>
}
| addSubscription(ui(mConsumerDao.queryAll()).subscribe(mAdapter));
|
18,321 | AddConsumerActivity.start(activity, AddConsumerActivity.TYPE_ADD, null);
}
@Override public void onItemClick(RecyclerView.ViewHolder viewHolder, View view, int position) {
AddConsumerActivity.start(activity, AddConsumerActivity.TYPE_MODIFY, mAdapter.getItem(position));
}
<BUG>@Override public void onItemLongClick(RecyclerView.ViewHolder viewHolder, View view, final int position) {
new MaterialDialog.Builder(activity)
.backgroundColorRes(R.color.white)</BUG>
.content(R.string.delete_dialog_content)
.contentColorRes(R.color.primary_light)
| new MaterialDialog.Builder(activity).backgroundColorRes(R.color.white)
|
18,322 | import com.classic.car.app.CarApplication;
import com.classic.car.db.dao.ConsumerDao;
import com.classic.car.ui.adapter.TimelineAdapter;
import com.classic.car.ui.base.AppBaseFragment;
import javax.inject.Inject;
<BUG>import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;</BUG>
public class TimelineFragment extends AppBaseFragment {
@BindView(R.id.timeline_recycler_view) RecyclerView mRecyclerView;
@Inject ConsumerDao mConsumerDao;
| [DELETED] |
18,323 | ((CarApplication)activity.getApplicationContext()).getAppComponent().inject(this);
super.initView(parentView, savedInstanceState);
mRecyclerView.setLayoutManager(new LinearLayoutManager(mAppContext));
mAdapter = new TimelineAdapter(mAppContext, R.layout.item_timeline);
mRecyclerView.setAdapter(mAdapter);
<BUG>addSubscription(mConsumerDao.queryAll()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.unsubscribeOn(Schedulers.io())
.subscribe(mAdapter));</BUG>
}
| addSubscription(ui(mConsumerDao.queryAll()).subscribe(mAdapter));
|
18,324 | public FSMAdapter() {
super(simplefsm.fsm.adapters.fsmmt.FsmMTAdaptersFactory.getInstance()) ;
}
@Override
public EList<State> getOwnedState() {
<BUG>return fr.inria.diverse.melange.adapters.EListAdapter.newInstance(adaptee.getOwnedState(), simplefsm.fsm.adapters.fsmmt.StateAdapter.class) ;
}</BUG>
@Override
public State getInitialState() {
return adaptersFactory.createStateAdapter(adaptee.getInitialState()) ;
| return EListAdapter.newInstance(adaptee.getOwnedState(), simplefsm.fsm.adapters.fsmmt.StateAdapter.class) ;
|
18,325 |
import simplefsm.fsmmt.Transition;
</BUG>
@SuppressWarnings("all")
<BUG>public class StateAdapter extends EObjectAdapter<State> implements simplefsm.fsmmt.State {
</BUG>
private FsmMTAdaptersFactory adaptersFactory;
public StateAdapter() {
super(simplefsm.fsm.adapters.fsmmt.FsmMTAdaptersFactory.getInstance()) ;
}
| package simplefsm.fsm.adapters.fsmmt;
import fr.inria.diverse.melange.adapters.EListAdapter;
import fr.inria.diverse.melange.adapters.EObjectAdapter;
import fsm.State;
import org.eclipse.emf.common.util.EList;
import simplefsm.fsm.adapters.fsmmt.FsmMTAdaptersFactory;
import simplefsm.fsmmt.fsm.FSM;
import simplefsm.fsmmt.fsm.Transition;
public class StateAdapter extends EObjectAdapter<State> implements simplefsm.fsmmt.fsm.State {
|
18,326 | package simplefsm;
<BUG>import fr.inria.diverse.melange.lib.IMetamodel;
import org.eclipse.emf.ecore.resource.Resource;
import simplefsm.FsmMT;</BUG>
import simplefsm.TimedFsmMT;
@SuppressWarnings("all")
| import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import simplefsm.FsmMT;
|
18,327 | }
public void setResource(final Resource resource) {
this.resource = resource;
}
public static TimedFsm load(final String uri) {
<BUG>org.eclipse.emf.ecore.resource.ResourceSet rs = new org.eclipse.emf.ecore.resource.impl.ResourceSetImpl() ;
Resource res = rs.getResource(org.eclipse.emf.common.util.URI.createURI(uri), true) ;
TimedFsm mm = new TimedFsm() ;</BUG>
mm.setResource(res) ;
return mm ;
| ResourceSet rs = new ResourceSetImpl() ;
Resource res = rs.getResource(URI.createURI(uri), true) ;
TimedFsm mm = new TimedFsm() ;
|
18,328 | package simplefsm.fsm.adapters.fsmmt;
import fr.inria.diverse.melange.adapters.ResourceAdapter;
<BUG>import java.io.IOException;
import simplefsm.FsmMT;
import simplefsm.fsmmt.FsmMTFactory;
</BUG>
@SuppressWarnings("all")
| import org.eclipse.emf.common.util.URI;
import simplefsm.fsmmt.fsm.FsmFactory;
|
18,329 | instance = new simplefsm.fsm.adapters.fsmmt.FsmMTAdaptersFactory() ;
}
return instance ;
}
public EObjectAdapter createAdapter(final EObject o) {
<BUG>EObjectAdapter res = register.get(o);
if(res != null){
return res;
}
else{</BUG>
if (o instanceof fsm.FSM){
| [DELETED] |
18,330 | register.put(o,res);
return res;</BUG>
}
if (o instanceof fsm.Transition){
<BUG>res = createTransitionAdapter((fsm.Transition) o) ;
register.put(o,res);
return res;
}</BUG>
}
| instance = new simplefsm.fsm.adapters.fsmmt.FsmMTAdaptersFactory() ;
return instance ;
public EObjectAdapter createAdapter(final EObject o) {
if (o instanceof fsm.FSM){
return createFSMAdapter((fsm.FSM) o) ;
if (o instanceof fsm.State){
return createStateAdapter((fsm.State) o) ;
return createTransitionAdapter((fsm.Transition) o) ;
|
18,331 | <BUG>package simplefsm;
@SuppressWarnings("all")</BUG>
public class StandaloneSetup {
public static void doSetup() {
StandaloneSetup setup = new StandaloneSetup() ;
| import fr.inria.diverse.melange.resource.MelangeRegistry;
import fr.inria.diverse.melange.resource.MelangeRegistryImpl;
import fr.inria.diverse.melange.resource.MelangeResourceFactoryImpl;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
@SuppressWarnings("all")
|
18,332 | package simplefsm;
<BUG>import fr.inria.diverse.melange.lib.IMetamodel;
import org.eclipse.emf.ecore.resource.Resource;
import simplefsm.FsmMT;</BUG>
@SuppressWarnings("all")
public class Fsm implements IMetamodel {
| import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import simplefsm.FsmMT;
|
18,333 | }
public void setResource(final Resource resource) {
this.resource = resource;
}
public static Fsm load(final String uri) {
<BUG>org.eclipse.emf.ecore.resource.ResourceSet rs = new org.eclipse.emf.ecore.resource.impl.ResourceSetImpl() ;
Resource res = rs.getResource(org.eclipse.emf.common.util.URI.createURI(uri), true) ;
Fsm mm = new Fsm() ;</BUG>
mm.setResource(res) ;
return mm ;
| ResourceSet rs = new ResourceSetImpl() ;
Resource res = rs.getResource(URI.createURI(uri), true) ;
Fsm mm = new Fsm() ;
|
18,334 | if (!changed.isEmpty())
{
logger.info( "Iterating for standard overrides..." );
for ( final String key : state.getVersionPropertyOverrides().keySet() )
{
<BUG>boolean found = PropertiesUtils.updateProperties( session, changed, true, key, state.getVersionPropertyOverride( key ) );
if ( !found )
{</BUG>
logger.info( "Unable to find a property for {} to update", key );
| PropertiesUtils.PropertyUpdate found = PropertiesUtils.updateProperties( session, changed, true, key, state.getVersionPropertyOverride( key ) );
if ( found == PropertiesUtils.PropertyUpdate.NOTFOUND )
|
18,335 | if (!result.isEmpty())
{
logger.info ("Iterating for standard overrides...");
for ( final String key : versionPropertyUpdateMap.keySet() )
{
<BUG>boolean found = PropertiesUtils.updateProperties( session, result, false, key, versionPropertyUpdateMap.get( key ) );
if ( !found )
{</BUG>
logger.info( "Unable to find a property for {} to update", key );
| PropertiesUtils.PropertyUpdate found = PropertiesUtils.updateProperties( session, result, false, key, versionPropertyUpdateMap.get( key ) );
if ( found == PropertiesUtils.PropertyUpdate.NOTFOUND )
|
18,336 | }
}
logger.info ("Iterating for explicit overrides...");
for ( final String key : explicitVersionPropertyUpdateMap.keySet() )
{
<BUG>boolean found = PropertiesUtils.updateProperties( session, result, true, key, explicitVersionPropertyUpdateMap.get( key ) );
if ( !found )
{</BUG>
logger.info( "Unable to find a property for {} to update for explicit overrides", key );
| if (!result.isEmpty())
logger.info ("Iterating for standard overrides...");
for ( final String key : versionPropertyUpdateMap.keySet() )
PropertiesUtils.PropertyUpdate found = PropertiesUtils.updateProperties( session, result, false, key, versionPropertyUpdateMap.get( key ) );
if ( found == PropertiesUtils.PropertyUpdate.NOTFOUND )
logger.info( "Unable to find a property for {} to update", key );
|
18,337 | logger.info( "Looking for new version: " + gav + " (found: " + newVersion + ")" );
if ( newVersion != null && model.getVersion() != null )
{
if (gav.getVersionString().startsWith( "${" ))
{
<BUG>PropertiesUtils.updateProperties( session, new HashSet<>( projects ), false, extractPropertyName( gav.getVersionString() ), newVersion );
}</BUG>
else
{
| if ( PropertiesUtils.updateProperties( session, new HashSet<>( projects ), false, extractPropertyName( gav.getVersionString() ), newVersion ) == PropertiesUtils.PropertyUpdate.NOTFOUND )
logger.error( "Unable to find property {} to update with version {}", gav.getVersionString(), newVersion );
}
}
|
18,338 | matchedProperties.put( trimmedPropertyName, value );
}
}
return matchedProperties;
}
<BUG>public static boolean updateProperties( ManipulationSession session, Set<Project> projects, boolean ignoreStrict,
String key, String newValue )
throws ManipulationException</BUG>
{
| public static PropertyUpdate updateProperties( ManipulationSession session, Set<Project> projects, boolean ignoreStrict,
String key, String newValue ) throws ManipulationException
|
18,339 |
String key, String newValue )
throws ManipulationException</BUG>
{
final DependencyState state = session.getState( DependencyState.class );
<BUG>boolean found = false;
final String resolvedValue = resolveProperties( new ArrayList<>( projects ) , "${" + key + '}');
logger.debug ("Fully resolvedValue is {} for {} ", resolvedValue, key);
</BUG>
if ( resolvedValue.equals( newValue ) )
| matchedProperties.put( trimmedPropertyName, value );
}
}
return matchedProperties;
}
public static PropertyUpdate updateProperties( ManipulationSession session, Set<Project> projects, boolean ignoreStrict,
String key, String newValue ) throws ManipulationException
PropertyUpdate found = PropertyUpdate.NOTFOUND;
final String resolvedValue = resolveProperties( new ArrayList<>( projects ), "${" + key + '}' );
logger.debug( "Fully resolvedValue is {} for {} ", resolvedValue, key );
|
18,340 |
logger.debug ("Fully resolvedValue is {} for {} ", resolvedValue, key);
</BUG>
if ( resolvedValue.equals( newValue ) )
{
<BUG>logger.warn( "Nothing to update as original key {} value matches new value {} ", key, newValue);
return false;
}</BUG>
for ( final Project p : projects )
| matchedProperties.put( trimmedPropertyName, value );
}
}
return matchedProperties;
}
public static PropertyUpdate updateProperties( ManipulationSession session, Set<Project> projects, boolean ignoreStrict,
String key, String newValue ) throws ManipulationException
|
18,341 | {
if ( p.getModel().getProperties().containsKey( key ) )
{
final String oldValue = p.getModel().getProperties().getProperty( key );
logger.info( "Updating property {} / {} with {} ", key, oldValue, newValue );
<BUG>found = true;
if ( oldValue != null && oldValue.startsWith( "${" ) && oldValue.endsWith( "}" ) &&
! ( StringUtils.countMatches( oldValue, "${" ) > 1 ) )
{
logger.debug ("Recursively resolving {} ", oldValue.substring( 2, oldValue.length() -1 ) );
if ( !updateProperties( session, projects, ignoreStrict, oldValue.substring( 2, oldValue.length() -1 ),
newValue ) )
{</BUG>
logger.error( "Recursive property not found for {} with {} ", oldValue, newValue );
| final String trimmedPropertyName = propertyName.substring( prefixLength );
String value = properties.getProperty( propertyName );
if ( value != null && value.equals( "true" ) )
|
18,342 | continue;
}
}
}
if ( oldValue != null && oldValue.contains( "${" ) &&
<BUG>! ( oldValue.startsWith( "${" ) && oldValue.endsWith( "}" ) ) ||
( StringUtils.countMatches( oldValue, "${" ) > 1 ) )
{</BUG>
if ( ignoreStrict )
| !( oldValue.startsWith( "${" ) && oldValue.endsWith( "}" ) ) || (
|
18,343 |
( StringUtils.countMatches( oldValue, "${" ) > 1 ) )
{</BUG>
if ( ignoreStrict )
{
<BUG>throw new ManipulationException( "NYI : handling for versions with explicit overrides (" + oldValue
+ ") with multiple embedded properties is NYI. " );
}
newValue = oldValue + StringUtils.removeStart( newValue, resolvedValue );
logger.info ("Ignoring new value due to embedded property {} and appending {} ", oldValue, newValue);
}</BUG>
p.getModel().getProperties().setProperty( key, newValue );
| continue;
if ( oldValue != null && oldValue.contains( "${" ) &&
!( oldValue.startsWith( "${" ) && oldValue.endsWith( "}" ) ) || (
throw new ManipulationException(
"NYI : handling for versions with explicit overrides (" + oldValue + ") with multiple embedded properties is NYI. " );
|
18,344 | </BUG>
{
suffix = state.getIncrementalSerialSuffix();
}
<BUG>else if ( state.getSuffix() != null && !state.getSuffix().isEmpty())
</BUG>
{
suffix = state.getSuffix().substring( 0, state.getSuffix().indexOf( '-' ) );
}
Version v = new Version( oldValue );
| final DependencyState dState = session.getState( DependencyState.class );
final boolean ignoreSuffix = dState.getStrictIgnoreSuffix();
final VersioningState state = session.getState( VersioningState.class );
String newVersion = newValue;
String suffix = null;
if ( state.getIncrementalSerialSuffix() != null && !state.getIncrementalSerialSuffix().isEmpty() )
else if ( state.getSuffix() != null && !state.getSuffix().isEmpty() )
|
18,345 | Version v = new Version( oldValue );
String osgiVersion = v.getOSGiVersionString();
HashSet<String> s = new HashSet<>();
s.add( oldValue );
s.add( newValue );
<BUG>if (ignoreSuffix)
</BUG>
{
String x = String.valueOf( Version.findHighestMatchingBuildNumber( v, s ) );
if ( newValue.endsWith( x ) )
| if ( ignoreSuffix )
|
18,346 | {
v.appendQualifierSuffix( suffix );
osgiVersion = v.getOSGiVersionString();
osgiVersion = osgiVersion.substring( 0, osgiVersion.indexOf( suffix ) - 1 );
}
<BUG>if (suffix != null && newValue.contains( suffix ) )
</BUG>
{
newVersion = newValue.substring( 0, newValue.indexOf( suffix ) - 1 );
}
| String x = String.valueOf( Version.findHighestMatchingBuildNumber( v, s ) );
if ( newValue.endsWith( x ) )
|
18,347 | boolean result = false;
if ( oldVersion != null && oldVersion.contains( "${" ) )
{
final int endIndex = oldVersion.indexOf( '}' );
final String oldProperty = oldVersion.substring( 2, endIndex );
<BUG>if ( oldVersion.contains( "${" ) &&
! ( oldVersion.startsWith( "${" ) && oldVersion.endsWith( "}" ) ) ||
( StringUtils.countMatches( oldVersion, "${" ) > 1 ) )
{
logger.debug ("For {} ; original version contains hardcoded value or multiple embedded properties. Not caching value ( {} -> {} )",
</BUG>
originalType, oldVersion, newVersion );
| if ( oldValue.equals( newVersion ) || osgiVersion.equals( newVersion ) )
result = true;
|
18,348 | import com.datumbox.framework.common.persistentstorage.interfaces.DatabaseConfiguration;
import java.io.File;
public abstract class AbstractFileDBConfiguration implements DatabaseConfiguration {
protected String outputDirectory = null;
@Override
<BUG>public String getDBnameSeparator() {
</BUG>
return File.separator;
}
public String getOutputDirectory() {
| public String getDBNameSeparator() {
|
18,349 | import com.datumbox.framework.common.interfaces.Trainable;
import com.datumbox.framework.core.machinelearning.common.interfaces.Parallelizable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
<BUG>public class TrainableBundle implements AutoCloseable {
private final Map<String, Trainable> bundle = new HashMap<>();</BUG>
public Set<String> keySet() {
return bundle.keySet();
| public class TrainableBundle implements Savable {
private final String dbNameSeparator;
public TrainableBundle(String dbNameSeparator) {
this.dbNameSeparator = dbNameSeparator;
}
private final Map<String, Trainable> bundle = new HashMap<>();
|
18,350 | import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public abstract class AbstractBoostingBagging<MP extends AbstractBoostingBagging.AbstractModelParameters, TP extends AbstractBoostingBagging.AbstractTrainingParameters> extends AbstractClassifier<MP, TP> {
<BUG>private final TrainableBundle bundle = new TrainableBundle();
private static final String DB_INDICATOR = "Cmp";</BUG>
private static final int MAX_NUM_OF_RETRIES = 2;
public static abstract class AbstractModelParameters extends AbstractClassifier.AbstractModelParameters {
private List<Double> weakClassifierWeights = new ArrayList<>();
| private final TrainableBundle bundle;
private static final String DB_INDICATOR = "Cmp";
|
18,351 | private void initBundle() {
Configuration conf = knowledgeBase.getConf();
DatabaseConnector dbc = knowledgeBase.getDbc();
MP modelParameters = knowledgeBase.getModelParameters();
TP trainingParameters = knowledgeBase.getTrainingParameters();
<BUG>String separator = conf.getDbConfig().getDBnameSeparator();
</BUG>
Class<AbstractClassifier> weakClassifierClass = trainingParameters.getWeakClassifierTrainingParameters().getTClass();
int totalWeakClassifiers = Math.min(modelParameters.getWeakClassifierWeights().size(), trainingParameters.getMaxWeakClassifiers());
for(int i=0;i<totalWeakClassifiers;i++) {
| String separator = conf.getDbConfig().getDBNameSeparator();
|
18,352 | import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class StepwiseRegression extends AbstractRegressor<StepwiseRegression.ModelParameters, StepwiseRegression.TrainingParameters> {
private static final String REG_KEY = "reg";
<BUG>private final TrainableBundle bundle = new TrainableBundle();
public static class ModelParameters extends AbstractRegressor.AbstractModelParameters {</BUG>
private static final long serialVersionUID = 1L;
protected ModelParameters(DatabaseConnector dbc) {
super(dbc);
| private final TrainableBundle bundle;
public static class ModelParameters extends AbstractRegressor.AbstractModelParameters {
|
18,353 | copiedTrainingData.delete();
}
@Override
public void save(String dbName) {
initBundle();
<BUG>super.save(dbName);
String separator = knowledgeBase.getConf().getDbConfig().getDBnameSeparator();
String knowledgeBaseName = createKnowledgeBaseName(dbName, separator);
bundle.save(knowledgeBaseName, separator);
}</BUG>
@Override
| String knowledgeBaseName = createKnowledgeBaseName(dbName, knowledgeBase.getConf().getDbConfig().getDBNameSeparator());
bundle.save(knowledgeBaseName);
|
18,354 | import com.datumbox.framework.common.Configuration;
import com.datumbox.framework.common.concurrency.ForkJoinStream;
import com.datumbox.framework.common.concurrency.StreamMethods;
import com.datumbox.framework.common.concurrency.ThreadMethods;
import com.datumbox.framework.common.interfaces.Copyable;
<BUG>import com.datumbox.framework.common.interfaces.Extractable;
import com.datumbox.framework.common.persistentstorage.abstracts.BigMapHolder;</BUG>
import com.datumbox.framework.common.persistentstorage.interfaces.BigMap;
import com.datumbox.framework.common.persistentstorage.interfaces.DatabaseConnector;
import com.datumbox.framework.common.persistentstorage.interfaces.DatabaseConnector.MapType;
| import com.datumbox.framework.common.interfaces.Savable;
import com.datumbox.framework.common.persistentstorage.abstracts.BigMapHolder;
|
18,355 | import java.io.*;
import java.net.URI;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
<BUG>public class Dataframe implements Collection<Record>, Copyable<Dataframe>, AutoCloseable {
</BUG>
public static final String COLUMN_NAME_Y = "~Y";
public static final String COLUMN_NAME_CONSTANT = "~CONSTANT";
public static class Builder {
| public class Dataframe implements Collection<Record>, Copyable<Dataframe>, Savable {
|
18,356 | }
protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final KnowledgeBase<MP, TP> knowledgeBase;
private boolean persisted;
protected AbstractTrainer(TP trainingParameters, Configuration conf) {
<BUG>String knowledgeBaseName = createKnowledgeBaseName("kb" + RandomGenerator.getThreadLocalRandomUnseeded().nextLong(), conf.getDbConfig().getDBnameSeparator());
</BUG>
knowledgeBase = new KnowledgeBase<>(knowledgeBaseName, conf, trainingParameters);
persisted = false;
}
| public static abstract class AbstractTrainingParameters implements TrainingParameters {
String knowledgeBaseName = createKnowledgeBaseName("kb" + RandomGenerator.getThreadLocalRandomUnseeded().nextLong(), conf.getDbConfig().getDBNameSeparator());
|
18,357 | _fit(trainingData);
}
@Override
public void save(String dbName) {
logger.info("save()");
<BUG>String knowledgeBaseName = createKnowledgeBaseName(dbName, knowledgeBase.getConf().getDbConfig().getDBnameSeparator());
</BUG>
knowledgeBase.save(knowledgeBaseName);
persisted = true;
}
| String knowledgeBaseName = createKnowledgeBaseName(dbName, knowledgeBase.getConf().getDbConfig().getDBNameSeparator());
|
18,358 | import com.datumbox.framework.core.machinelearning.common.interfaces.Parallelizable;
public class Modeler extends AbstractTrainer<Modeler.ModelParameters, Modeler.TrainingParameters> implements Parallelizable {
private static final String DT_KEY = "dt";
private static final String FS_KEY = "fs";
private static final String ML_KEY = "ml";
<BUG>private final TrainableBundle bundle = new TrainableBundle();
public static class ModelParameters extends AbstractTrainer.AbstractModelParameters {</BUG>
private static final long serialVersionUID = 1L;
protected ModelParameters(DatabaseConnector dbc) {
super(dbc);
| private final TrainableBundle bundle;
public static class ModelParameters extends AbstractTrainer.AbstractModelParameters {
|
18,359 | }
@RootTask
static Task<Exec.Result> exec(String parameter, int number) {
Task<String> task1 = MyTask.create(parameter);
Task<Integer> task2 = Adder.create(number, number + 2);
<BUG>return Task.ofType(Exec.Result.class).named("exec", "/bin/sh")
.in(() -> task1)</BUG>
.in(() -> task2)
.process(Exec.exec((str, i) -> args("/bin/sh", "-c", "\"echo " + i + "\"")));
}
| return Task.named("exec", "/bin/sh").ofType(Exec.Result.class)
.in(() -> task1)
|
18,360 | return args;
}
static class MyTask {
static final int PLUS = 10;
static Task<String> create(String parameter) {
<BUG>return Task.ofType(String.class).named("MyTask", parameter)
.in(() -> Adder.create(parameter.length(), PLUS))</BUG>
.in(() -> Fib.create(parameter.length()))
.process((sum, fib) -> something(parameter, sum, fib));
}
| return Task.named("MyTask", parameter).ofType(String.class)
.in(() -> Adder.create(parameter.length(), PLUS))
|
18,361 | final String instanceField = "from instance";
final TaskContext context = TaskContext.inmem();
final AwaitingConsumer<String> val = new AwaitingConsumer<>();
@Test
public void shouldJavaUtilSerialize() throws Exception {
<BUG>Task<Long> task1 = Task.ofType(Long.class).named("Foo", "Bar", 39)
.process(() -> 9999L);
Task<String> task2 = Task.ofType(String.class).named("Baz", 40)
.in(() -> task1)</BUG>
.ins(() -> singletonList(task1))
| Task<Long> task1 = Task.named("Foo", "Bar", 39).ofType(Long.class)
Task<String> task2 = Task.named("Baz", 40).ofType(String.class)
.in(() -> task1)
|
18,362 | assertEquals(des.id().name(), "Baz");
assertEquals(val.awaitAndGet(), "[9999] hello 10004");
}
@Test(expected = NotSerializableException.class)
public void shouldNotSerializeWithInstanceFieldReference() throws Exception {
<BUG>Task<String> task = Task.ofType(String.class).named("WithRef")
.process(() -> instanceField + " causes an outer reference");</BUG>
serialize(task);
}
@Test
| Task<String> task = Task.named("WithRef").ofType(String.class)
.process(() -> instanceField + " causes an outer reference");
|
18,363 | serialize(task);
}
@Test
public void shouldSerializeWithLocalReference() throws Exception {
String local = instanceField;
<BUG>Task<String> task = Task.ofType(String.class).named("WithLocalRef")
.process(() -> local + " won't cause an outer reference");</BUG>
serialize(task);
Task<String> des = deserialize();
context.evaluate(des).consume(val);
| Task<String> task = Task.named("WithLocalRef").ofType(String.class)
.process(() -> local + " won't cause an outer reference");
|
18,364 | }
@RootTask
public static Task<String> standardArgs(int first, String second) {
firstInt = first;
secondString = second;
<BUG>return Task.ofType(String.class).named("StandardArgs", first, second)
.process(() -> second + " " + first * 100);</BUG>
}
@Test
public void shouldParseFlags() throws Exception {
| return Task.named("StandardArgs", first, second).ofType(String.class)
.process(() -> second + " " + first * 100);
|
18,365 | assertThat(parsedEnum, is(CustomEnum.BAR));
}
@RootTask
public static Task<String> enums(CustomEnum enm) {
parsedEnum = enm;
<BUG>return Task.ofType(String.class).named("Enums", enm)
.process(enm::toString);</BUG>
}
@Test
public void shouldParseCustomTypes() throws Exception {
| return Task.named("Enums", enm).ofType(String.class)
.process(enm::toString);
|
18,366 | assertThat(parsedType.content, is("blarg parsed for you!"));
}
@RootTask
public static Task<String> customType(CustomType myType) {
parsedType = myType;
<BUG>return Task.ofType(String.class).named("Types", myType.content)
.process(() -> myType.content);</BUG>
}
public enum CustomEnum {
BAR
| return Task.named("Types", myType.content).ofType(String.class)
.process(() -> myType.content);
|
18,367 | TaskContext taskContext = TaskContext.inmem();
TaskContext.Value<Long> value = taskContext.evaluate(fib92);
value.consume(f92 -> System.out.println("fib(92) = " + f92));
}
static Task<Long> create(long n) {
<BUG>TaskBuilder<Long> fib = Task.ofType(Long.class).named("Fib", n);
</BUG>
if (n < 2) {
return fib
.process(() -> n);
| TaskBuilder<Long> fib = Task.named("Fib", n).ofType(Long.class);
|
18,368 | 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;
|
18,369 | 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;
|
18,370 | 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"),
|
18,371 | 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] |
18,372 | 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) {
|
18,373 | 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;
|
18,374 | package org.jenkinsci.plugins.dockerbuildstep;
<BUG>import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang.StringUtils.isEmpty;
import hudson.AbortException;</BUG>
import hudson.DescriptorExtensionList;
import hudson.Extension;
| import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.DockerException;
import com.github.dockerjava.api.command.DockerCmdExecFactory;
import com.github.dockerjava.api.model.AuthConfig;
import com.github.dockerjava.core.DockerClientBuilder;
import com.github.dockerjava.core.DockerClientConfig.DockerClientConfigBuilder;
import com.github.dockerjava.core.SSLConfig;
import com.github.dockerjava.jaxrs.DockerCmdExecFactoryImpl;
import hudson.AbortException;
|
18,375 | import org.jenkinsci.plugins.dockerbuildstep.cmd.DockerCommand.DockerCommandDescriptor;
import org.jenkinsci.plugins.dockerbuildstep.log.ConsoleLogger;
import org.jenkinsci.plugins.dockerbuildstep.util.Resolver;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
<BUG>import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.DockerException;
import com.github.dockerjava.api.model.AuthConfig;
import com.github.dockerjava.core.DockerClientBuilder;
import com.github.dockerjava.core.DockerClientConfig.DockerClientConfigBuilder;
import com.github.dockerjava.core.SSLConfig;
public class DockerBuilder extends Builder {</BUG>
private DockerCommand dockerCmd;
| import java.util.logging.Level;
import java.util.logging.Logger;
import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang.StringUtils.isEmpty;
public class DockerBuilder extends Builder {
|
18,376 | NoSuchAlgorithmException, KeyStoreException {
return null;
}
});
DockerClientConfigBuilder configBuilder = new DockerClientConfigBuilder().withUri(dockerUrl)
<BUG>.withVersion(dockerVersion).withSSLConfig(dummySSLConf)
.withMaxTotalConnections(1).withMaxPerRouteConnections(1);</BUG>
if (authConfig != null) {
configBuilder.withUsername(authConfig.getUsername())
| .withVersion(dockerVersion).withSSLConfig(dummySSLConf);
|
18,377 | configBuilder.withUsername(authConfig.getUsername())
.withEmail(authConfig.getEmail())
.withPassword(authConfig.getPassword())
.withServerAddress(authConfig.getServerAddress());
}
<BUG>ClassLoader classLoader = Jenkins.getInstance().getPluginManager().uberClassLoader;
return DockerClientBuilder.getInstance(configBuilder).withServiceLoaderClassLoader(classLoader).build();
</BUG>
}
public FormValidation doTestConnection(@QueryParameter String dockerUrl, @QueryParameter String dockerVersion) {
| DockerCmdExecFactory dockerCmdExecFactory = new DockerCmdExecFactoryImpl()
.withReadTimeout(1000)
.withConnectTimeout(1000)
.withMaxTotalConnections(1)
.withMaxPerRouteConnections(1);
return DockerClientBuilder.getInstance(configBuilder).withDockerCmdExecFactory(dockerCmdExecFactory).build();
|
18,378 | return dockerVersion;
}
public DockerClient getDockerClient(AuthConfig authConfig) {
return createDockerClient(dockerUrl, dockerVersion, authConfig);
}
<BUG>public DockerClient getDockerClient(AbstractBuild<?,?> build, AuthConfig authConfig) {
</BUG>
String dockerUrlRes = build == null ? Resolver.envVar(dockerUrl) : Resolver.buildVar(build, dockerUrl);
String dockerVersionRes = build == null ? Resolver.envVar(dockerVersion) : Resolver.buildVar(build, dockerVersion);
return createDockerClient(dockerUrlRes, dockerVersionRes, authConfig);
| public DockerClient getDockerClient(AbstractBuild<?, ?> build, AuthConfig authConfig) {
|
18,379 | 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;
|
18,380 | 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;
|
18,381 | 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"),
|
18,382 | 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] |
18,383 | 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) {
|
18,384 | 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;
|
18,385 | import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
<BUG>import org.apache.log4j.Category;
import org.exolab.castor.xml.MarshalException;</BUG>
import org.exolab.castor.xml.ValidationException;
import org.opennms.core.utils.ThreadCategory;
import org.opennms.netmgt.config.syslogd.HideMatch;
| import org.apache.log4j.Level;
import org.exolab.castor.xml.MarshalException;
|
18,386 | Value parmValue = null;
Pattern msgPat;
Matcher msgMat;
for (UeiMatch uei : ueiList.getUeiMatchCollection()) {
if (uei.getMatch().getType().equals("substr")) {
<BUG>if (log.isDebugEnabled()) {
log.debug("Attempting substring match for text of a Syslogd event to :" + uei.getMatch().getExpression());
</BUG>
}
if (message.contains(uei.getMatch().getExpression())) {
| if (traceEnabled) {
log.log(Level.TRACE, "Attempting substring match for text of a Syslogd event to :" + uei.getMatch().getExpression());
|
18,387 | } else if (hide.getMatch().getType().equals("regex")) {
try {
msgPat = Pattern.compile(hide.getMatch().getExpression(), Pattern.MULTILINE);
msgMat = msgPat.matcher(message);
} catch (PatternSyntaxException pse) {
<BUG>log.error("Failed to compile regex pattern '"+hide.getMatch().getExpression()+"'", pse);
</BUG>
msgMat = null;
}
if ((msgMat != null) && (msgMat.matches())) {
| log.warn("Failed to compile regex pattern '"+hide.getMatch().getExpression()+"'", pse);
|
18,388 | processIdStr = message.substring(lbIdx + 1, rbIdx);
message = message.substring(colonIdx + 2);
try {
processId = Integer.parseInt(processIdStr);
} catch (NumberFormatException ex) {
<BUG>log.debug("ERROR Bad process id '" + processIdStr + "'");
processId = 0;</BUG>
}
} else if (lbIdx < 0 && rbIdx < 0 && colonIdx > 0 && spaceIdx == (colonIdx + 1)) {
processName = message.substring(0, colonIdx);
| log.debug("Bad process id '" + processIdStr + "'");
processId = 0;
|
18,389 | import sparkjni.jniLink.linkContainers.TypeMapper;
import sparkjni.utils.CppSyntax;
import sparkjni.utils.JniUtils;
import sparkjni.utils.cpp.fields.CppField;
import javax.annotation.Nullable;
<BUG>import java.util.List;
@Value.Immutable</BUG>
public abstract class UserNativeFunction {
public abstract FunctionSignatureMapper functionSignatureMapper();
private Optional<String> functionBodyCodeInsertion = Optional.absent();
| import static sparkjni.utils.JniUtils.PASS_BY_REFERENCE;
import static sparkjni.utils.JniUtils.PASS_BY_VALUE;
@Value.Immutable
|
18,390 | public abstract class UserNativeFunction {
public abstract FunctionSignatureMapper functionSignatureMapper();
private Optional<String> functionBodyCodeInsertion = Optional.absent();
String generateUserFunctionPrototype() {
FunctionSignatureMapper functionSignatureMapper = functionSignatureMapper();
<BUG>String prototypeArgumentList = generatePrototypeArgumentListDefinition(functionSignatureMapper);
return String.format(CppSyntax.FUNCTION_PROTOTYPE_STR.substring(1),
CppSyntax.NO_ADDITIONAL_INDENTATION, functionSignatureMapper.returnTypeMapper().cppType().getCppClassName() + "*",
functionSignatureMapper.functionNameMapper().javaName(), prototypeArgumentList);</BUG>
}
| String returnType = JniUtils.wrapInSharedPtr(functionSignatureMapper.returnTypeMapper().cppType().getCppClassName(), PASS_BY_VALUE);
CppSyntax.NO_ADDITIONAL_INDENTATION, returnType,
functionSignatureMapper.functionNameMapper().javaName(), prototypeArgumentList);
|
18,391 | private String generatePrototypeArgumentListDefinition(FunctionSignatureMapper functionSignatureMapper) {
StringBuilder stringBuilder = new StringBuilder();
List<TypeMapper> typeMapperList = functionSignatureMapper.parameterList();
int ctr = 0;
for (TypeMapper typeMapper : typeMapperList) {
<BUG>stringBuilder.append(String.format("%s *%s, ",
typeMapper.cppType().getCppClassName(),
JniUtils.generateCppVariableName(typeMapper.cppType(), null, ctr++)</BUG>
));
}
| stringBuilder.append(String.format("%s %s, ",
JniUtils.wrapInSharedPtr(typeMapper.cppType().getCppClassName(), PASS_BY_REFERENCE),
JniUtils.generateCppVariableName(typeMapper.cppType(), null, ctr++)
|
18,392 | argsListBuilder.append(cppField.getDefaultInitialization());
argsListBuilder.append(", ");
}
}
argsListBuilder.append(JniUtils.generateClassNameVariableName(returnCppBean, null));
<BUG>argsListBuilder.append(", jniEnv");
String initialization = String.format("\t%s *%s = new %s(%s);\n",
returnCppBean.getCppClassName(), returnTypeVariableName,
returnCppBean.getCppClassName(), argsListBuilder.toString());</BUG>
String returnStatement = String.format("\treturn %s;\n", returnTypeVariableName);
| String retType = JniUtils.wrapInSharedPtr(returnCppBean.getCppClassName(), PASS_BY_VALUE);
String initializationExpression = JniUtils.makeShared(returnCppBean.getCppClassName(), argsListBuilder.toString());
String initialization = String.format("\t%s %s = %s;\n",
retType, returnTypeVariableName, initializationExpression);
|
18,393 | public void deploy() {
deployTimesLogger.start = System.currentTimeMillis();
processCppContent();
loadNativeLib();
}
<BUG>public void deployWithCodeInjections(HashMap<String, String> functionCodeInjectorMap){
this.functionCodeInjectorMap = functionCodeInjectorMap;</BUG>
deploy();
}
private void loadNativeLib() {
| if(!functionCodeInjectorMap.isEmpty())
this.functionCodeInjectorMap = functionCodeInjectorMap;
|
18,394 | bodySb.append("\tif(jniCreated != 0){\n");
for (CppField field : ownerClass.getCppFields()) {
if (field instanceof CppRawTypeField) {
CppRawTypeField rawTypeField = (CppRawTypeField) field;
if (rawTypeField.isPrimitiveArray()) {
<BUG>bodySb.append("\t"+ String.format(
rawTypeField.isCriticalArray() ? CppSyntax.RELEASE_ARRAY_CRITICAL : CppSyntax.RELEASE_ARRAY_STATEMENT_STR,
JniUtils.getArrayElementType(rawTypeField.getJavaField()), field.getName() + "Arr", field.getName(), "0"));
}</BUG>
}
| String releaseStatement = rawTypeField.isCriticalArray() ?
String.format(CppSyntax.RELEASE_ARRAY_CRITICAL, field.getName() + "Arr", field.getName(), "0") :
String.format(CppSyntax.RELEASE_ARRAY_STATEMENT_STR,
JniUtils.getArrayElementType(rawTypeField.getJavaField()), field.getName() + "Arr", field.getName(), "0");
bodySb.append("\t");
bodySb.append(releaseStatement);
bodySb.append("\n");
|
18,395 | "\t%s(%s);\n"; // here we have variable number of arguments - personalized by user classes
public static final String CONSTRUCTOR_WITH_NATIVE_ARGS_IMPL_STR =
"%s::%s(%s){\n%s}\n"; // here we have variable number of arguments - personalized by user classes
public static final String CONSTRUCTOR_STMT_STR = "\t%s = %s;\n";
public static final String RELEASE_ARRAY_STATEMENT_STR = "env->Release%sArrayElements(%s, %s, %s);";
<BUG>public static final String CPP_OUT_FILE_STR = "%s\n%s\n%s\n%s";
public static final String JNI_CONSTRUCTOR_IMPL_STR = "%s (JNIEnv* env, jobject thisObj, jobject bean){\n%s}";
public static final String JNI_FUNCTION_BODY_STR = "%s\n\treturn bean;\n";
public static final String JNI_FUNCTION_BODY_STMT_STR = "\tjclass beanClass%d = env->GetObjectClass(bean);\n" +
"\t%s cppBean(beanClass%d, bean, env);\n";</BUG>
public static final String BEAN_HEADER_FILE_STR = "#ifndef %s\n#define %s\n" +
| [DELETED] |
18,396 | "public:\n%s\n};\n" +
"#endif";
public static final String SIMPLE_HEADER_FILE_STR = "#ifndef %s\n#define %s\n" +
"%s\n" +
"#endif";
<BUG>public static final String BEAN_CPP_FILE_STR = "%s\n" + // includes
"%s\n" + // fields
"%s\n"; // functions</BUG>
public static final String FUNCTION_PROTOTYPE_STR = "\t%s%s %s(%s);\n";
public static final String FUNCTION_IMPL_STR = "\t%s CPP%s::%s(%s){\n%s}\n";
| [DELETED] |
18,397 | public String getDefaultInitialization() {
switch (type){
case "int*":
return "new int[3]{1,2,3}";
case "int":
<BUG>return "3";
default:
return "ohhNOOO_ERROR";
}</BUG>
}
| case "double*":
return "new double[3]{1.0,2.0,3.0}";
return "ERROR: Unimplemented default initialization type";
|
18,398 | public static final String JNI_CLASS = "jclass";
public static final String JNI_STRING = "jstring";
public static final String JNI_ARRAY = "jarray";
public static final int DEFAULT_MEMORY_ALIGNMENT = 64;
public static final String NO_CRITICAL = "NO_CRITICAL";
<BUG>public static final String CRITICAL = "CRITICAL";
public static String getArrayElementType(Field field) {</BUG>
if (!field.getType().isArray())
throw new IllegalArgumentException(String.format(Messages.ERR_FIELD_WITH_TYPE_IS_NOT_AN_ARRAY,
field.getName(), field.getType().getName()));
| public static final boolean PASS_BY_VALUE = false;
public static final boolean PASS_BY_REFERENCE = true;
public static String getArrayElementType(Field field) {
|
18,399 | field.getName() + "_length", field.getName() + "Arr"));
if (cppRawTypeField.isMemoryAligned()) {
generateMemoryAlignedFieldInitStatement(cppRawTypeField, jniArrFieldName);
} else {
String typeCast = String.format("(%s)", field.getNativeType());
<BUG>sb.append(String.format(
cppRawTypeField.isCriticalArray() ? CppSyntax.GET_ARRAY_CRITICAL_ELEMENTS : CppSyntax.GET_ARRAY_ELEMENTS_STR,
cppRawTypeField.getName(), typeCast, cppRawTypeField.getTypeOfArrayElement(), jniArrFieldName
));
}</BUG>
}
| String getArrayStatement = cppRawTypeField.isCriticalArray() ?
String.format(CppSyntax.GET_ARRAY_CRITICAL_ELEMENTS, cppRawTypeField.getName(), typeCast, jniArrFieldName) :
String.format(CppSyntax.GET_ARRAY_ELEMENTS_STR,
cppRawTypeField.getName(), typeCast, cppRawTypeField.getTypeOfArrayElement(), jniArrFieldName);
sb.append(getArrayStatement);
|
18,400 | package sparkjni.jniLink.linkHandlers;
import junit.framework.TestCase;
<BUG>import org.junit.Ignore;
import sparkjni.dataLink.CppBean;
import sparkjni.jniLink.linkContainers.FunctionSignatureMapperTest;
import sparkjni.utils.JniLinkHandler;</BUG>
import org.junit.Assert;
| [DELETED] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.