Title: Getting OOM instead of FormatterException · Issue #441 · google/google-java-format · GitHub
Open Graph Title: Getting OOM instead of FormatterException · Issue #441 · google/google-java-format
X Title: Getting OOM instead of FormatterException · Issue #441 · google/google-java-format
Description: For the following example I am getting OOM error instead of FormatterException. /*package org.wso2.developerstudio.eclipse.gmf.esb.diagram.edit.parts; import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Graphics; import o...
Open Graph Description: For the following example I am getting OOM error instead of FormatterException. /*package org.wso2.developerstudio.eclipse.gmf.esb.diagram.edit.parts; import org.eclipse.draw2d.ColorConstants; impo...
X Description: For the following example I am getting OOM error instead of FormatterException. /*package org.wso2.developerstudio.eclipse.gmf.esb.diagram.edit.parts; import org.eclipse.draw2d.ColorConstants; impo...
Opengraph URL: https://github.com/google/google-java-format/issues/441
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Getting OOM instead of FormatterException","articleBody":"For the following example I am getting OOM error instead of FormatterException.\r\n```\r\n/*package org.wso2.developerstudio.eclipse.gmf.esb.diagram.edit.parts;\r\n\r\nimport org.eclipse.draw2d.ColorConstants;\r\nimport org.eclipse.draw2d.Graphics;\r\nimport org.eclipse.draw2d.GridLayout;\r\nimport org.eclipse.draw2d.IFigure;\r\nimport org.eclipse.draw2d.RoundedRectangle;\r\nimport org.eclipse.draw2d.Shape;\r\nimport org.eclipse.draw2d.StackLayout;\r\nimport org.eclipse.draw2d.ToolbarLayout;\r\nimport org.eclipse.draw2d.geometry.Dimension;\r\nimport org.eclipse.gef.EditPart;\r\nimport org.eclipse.gef.EditPolicy;\r\nimport org.eclipse.gef.Request;\r\nimport org.eclipse.gef.commands.Command;\r\nimport org.eclipse.gef.editpolicies.LayoutEditPolicy;\r\nimport org.eclipse.gef.editpolicies.NonResizableEditPolicy;\r\nimport org.eclipse.gef.requests.CreateRequest;\r\nimport org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;\r\nimport org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;\r\nimport org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;\r\nimport org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;\r\nimport org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;\r\nimport org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;\r\nimport org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;\r\nimport org.eclipse.gmf.runtime.notation.View;\r\nimport org.eclipse.swt.graphics.Color;\r\nimport org.wso2.developerstudio.eclipse.gmf.esb.diagram.edit.policies.ProxyServiceSequenceContainerCanonicalEditPolicy;\r\nimport org.wso2.developerstudio.eclipse.gmf.esb.diagram.edit.policies.ProxyServiceSequenceContainerItemSemanticEditPolicy;\r\n\r\n*//**\r\n * @generated\r\n *//*\r\npublic class ProxyServiceSequenceContainerEditPart extends ShapeNodeEditPart {\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tpublic static final int VISUAL_ID = 3391;\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tprotected IFigure contentPane;\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tprotected IFigure primaryShape;\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tpublic ProxyServiceSequenceContainerEditPart(View view) {\r\n\t\tsuper(view);\r\n\t}\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tprotected void createDefaultEditPolicies() {\r\n\t\tinstallEditPolicy(EditPolicyRoles.CREATION_ROLE,\r\n\t\t\t\tnew CreationEditPolicy());\r\n\t\tsuper.createDefaultEditPolicies();\r\n\t\tinstallEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,\r\n\t\t\t\tnew ProxyServiceSequenceContainerItemSemanticEditPolicy());\r\n\t\tinstallEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE,\r\n\t\t\t\tnew DragDropEditPolicy());\r\n\t\tinstallEditPolicy(EditPolicyRoles.CANONICAL_ROLE,\r\n\t\t\t\tnew ProxyServiceSequenceContainerCanonicalEditPolicy());\r\n\t\tinstallEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());\r\n\t\t// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies\r\n\t\t// removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);\r\n\t}\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tprotected LayoutEditPolicy createLayoutEditPolicy() {\r\n\t\torg.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() {\r\n\r\n\t\t\tprotected EditPolicy createChildEditPolicy(EditPart child) {\r\n\t\t\t\tEditPolicy result = child\r\n\t\t\t\t\t\t.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);\r\n\t\t\t\tif (result == null) {\r\n\t\t\t\t\tresult = new NonResizableEditPolicy();\r\n\t\t\t\t}\r\n\t\t\t\treturn result;\r\n\t\t\t}\r\n\r\n\t\t\tprotected Command getMoveChildrenCommand(Request request) {\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\r\n\t\t\tprotected Command getCreateCommand(CreateRequest request) {\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\t\t};\r\n\t\treturn lep;\r\n\t}\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tprotected IFigure createNodeShape() {\r\n\t\treturn primaryShape = new ProxyServiceSequenceContainerFigure();\r\n\t}\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tpublic ProxyServiceSequenceContainerFigure getPrimaryShape() {\r\n\t\treturn (ProxyServiceSequenceContainerFigure) primaryShape;\r\n\t}\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tprotected NodeFigure createNodePlate() {\r\n\t\tDefaultSizeNodeFigure result = new DefaultSizeNodeFigure(40, 40);\r\n\t\treturn result;\r\n\t}\r\n\r\n\t*//**\r\n\t * Creates figure for this edit part.\r\n\t *\r\n\t * Body of this method does not depend on settings in generation model\r\n\t * so you may safely remove \u003ci>generated\u003c/i> tag and modify it.\r\n\t *\r\n\t * @generated\r\n\t *//*\r\n\tprotected NodeFigure createNodeFigure() {\r\n\t\tNodeFigure figure = createNodePlate();\r\n\t\tfigure.setLayoutManager(new StackLayout());\r\n\t\tIFigure shape = createNodeShape();\r\n\t\tfigure.add(shape);\r\n\t\tcontentPane = setupContentPane(shape);\r\n\t\treturn figure;\r\n\t}\r\n\r\n\t*//**\r\n\t * Default implementation treats passed figure as content pane.\r\n\t * Respects layout one may have set for generated figure.\r\n\t * @param nodeShape instance of generated figure class\r\n\t * @generated\r\n\t *//*\r\n\tprotected IFigure setupContentPane(IFigure nodeShape) {\r\n\t\tif (nodeShape.getLayoutManager() == null) {\r\n\t\t\tConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();\r\n\t\t\tlayout.setSpacing(5);\r\n\t\t\tnodeShape.setLayoutManager(layout);\r\n\t\t}\r\n\t\treturn nodeShape; // use nodeShape itself as contentPane\r\n\t}\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tpublic IFigure getContentPane() {\r\n\t\tif (contentPane != null) {\r\n\t\t\treturn contentPane;\r\n\t\t}\r\n\t\treturn super.getContentPane();\r\n\t}\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tprotected void setForegroundColor(Color color) {\r\n\t\tif (primaryShape != null) {\r\n\t\t\tprimaryShape.setForegroundColor(color);\r\n\t\t}\r\n\t}\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tprotected void setBackgroundColor(Color color) {\r\n\t\tif (primaryShape != null) {\r\n\t\t\tprimaryShape.setBackgroundColor(color);\r\n\t\t}\r\n\t}\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tprotected void setLineWidth(int width) {\r\n\t\tif (primaryShape instanceof Shape) {\r\n\t\t\t((Shape) primaryShape).setLineWidth(width);\r\n\t\t}\r\n\t}\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tprotected void setLineType(int style) {\r\n\t\tif (primaryShape instanceof Shape) {\r\n\t\t\t((Shape) primaryShape).setLineStyle(style);\r\n\t\t}\r\n\t}\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tpublic class ProxyServiceSequenceContainerFigure extends RoundedRectangle {\r\n\r\n\t\t*//**\r\n\t\t * @generated NOT\r\n\t\t *//*\r\n\t\tpublic ProxyServiceSequenceContainerFigure() {\r\n\r\n\t\t\t\t\tGridLayout layoutThis = new GridLayout();\r\n\t\t\t\t\tlayoutThis.numColumns = 1;\r\n\t\t\t\t\tlayoutThis.makeColumnsEqualWidth = true;\r\n\t\t\t\t\tthis.setLayoutManager(layoutThis);\r\n\r\n\t\t\tToolbarLayout layoutThis = new ToolbarLayout();\r\n\t\t\tlayoutThis.setStretchMinorAxis(true);\r\n\t\t\tlayoutThis.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);\r\n\t\t\tlayoutThis.setSpacing(0);\r\n\t\t\tlayoutThis.setVertical(true);\r\n\r\n\t\t\tthis.setLayoutManager(layoutThis);\r\n\r\n\t\t\tthis.setCornerDimensions(new Dimension(getMapMode().DPtoLP(8),\r\n\t\t\t\t\tgetMapMode().DPtoLP(8)));\r\n\t\t\tthis.setLineStyle(Graphics.LINE_DASH);\r\n\t\t\tthis.setPreferredSize(new Dimension(getMapMode().DPtoLP(3000),\r\n\t\t\t\t\tgetMapMode().DPtoLP(500)));\r\n\t\t\tthis.setOutline(false);\r\n\r\n\t\t\tthis.setBackgroundColor(THIS_BACK);\r\n\t\t}\r\n\r\n\t\tprotected void fillShape(Graphics graphics) {\r\n\t\t\t// Backup the graphics colors\r\n\t\t\tColor bgColor = graphics.getBackgroundColor();\r\n\t\t\tColor fgColor = graphics.getForegroundColor();\r\n\t\t\t// Set the graphics color\r\n\t\t\tgraphics.setBackgroundColor(getBackgroundColor());\r\n\t\t\tgraphics.setForegroundColor(ColorConstants.white);\r\n\t\t\t// Restore the original colors\r\n\t\t\tgraphics.fillGradient(getBounds(), true);\r\n\t\t\tgraphics.setBackgroundColor(bgColor);\r\n\t\t\tgraphics.setForegroundColor(fgColor);\r\n\t\t}\r\n\r\n\t}\r\n\r\n\tpublic boolean isSelectable() {\r\n\t\t// TODO This or using ResizableEditpolicy?\r\n\t\treturn false;\r\n\t}\r\n\r\n\t*//**\r\n\t * @generated\r\n\t *//*\r\n\tstatic final Color THIS_BACK = new Color(null, 255, 255, 255);\r\n\r\n}\r\n*/\r\n```\r\n\r\nWhen I pass the example stated above to the Formatter I am getting the OOM, which I shouldn't expect.\r\nThe driver code I am using is \r\n\r\n```\r\npackage com.foo;\r\n\r\nimport com.google.googlejavaformat.java.Formatter;\r\nimport java.nio.file.Files;\r\nimport java.nio.file.Paths;\r\n\r\npublic class Playground {\r\n public static String readCode() throws Exception{\r\n return new String(Files.readAllBytes(Paths.get(\"example\")));\r\n }\r\n\r\n public static void main(String[] args) throws Exception{\r\n\r\n String code = readCode();\r\n System.out.println(code);\r\n\r\n Formatter formatter = new Formatter();\r\n String out = formatter.formatSource(code);\r\n System.out.println(out);\r\n }\r\n}\r\n```","author":{"url":"https://github.com/jayendra13","@type":"Person","name":"jayendra13"},"datePublished":"2020-03-13T08:46:46Z","url":"https://github.com/google/google-java-format/issues/441"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0dc35478-636f-60f0-d839-882836d5e0ce |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8296:1C1295:F1DC6:150A2B:6AFBCAB3 |
| html-safe-nonce | 66891282f0dfcc1350cf9684f7ee866a23cacc0bb2edbd4d9fc47e6677ed22a9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Mjk2OjFDMTI5NTpGMURDNjoxNTBBMkI6NkFGQkNBQjMiLCJ2aXNpdG9yX2lkIjoiODAyMzI5ODE2Njg2NDIwMjQxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2fd03bbbe762ce01fb0c28125eb27e1d90b09795f60caa6442220b557a4603f1 |
| hovercard-subject-tag | issue:580454581 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/google/google-java-format/441/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2093848d61c45770ea917400289214614e4a75a6b38e107dcf2a63a1ce000b0e/google/google-java-format/issues/441 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2093848d61c45770ea917400289214614e4a75a6b38e107dcf2a63a1ce000b0e/google/google-java-format/issues/441 |
| og:image:alt | For the following example I am getting OOM error instead of FormatterException. /*package org.wso2.developerstudio.eclipse.gmf.esb.diagram.edit.parts; import org.eclipse.draw2d.ColorConstants; impo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jayendra13 |
| hostname | github.com |
| expected-hostname | github.com |
| None | d440bda0d812801778b27bfe9f7c1ce9ff22420c73f6f95150c4fcbca311c50b |
| turbo-cache-control | no-preview |
| go-import | github.com/google/google-java-format git https://github.com/google/google-java-format.git |
| octolytics-dimension-user_id | 1342004 |
| octolytics-dimension-user_login | |
| octolytics-dimension-repository_id | 35448780 |
| octolytics-dimension-repository_nwo | google/google-java-format |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 35448780 |
| octolytics-dimension-repository_network_root_nwo | google/google-java-format |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2c43021aed8695990c86c0eaaedc600bfeffec36 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width